imp_res_6.phpt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. --TEST--
  2. Oracle Database 12c Implicit Result Sets: alternating oci_fetch_* calls
  3. --EXTENSIONS--
  4. oci8
  5. --SKIPIF--
  6. <?php
  7. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  8. require(__DIR__.'/skipif.inc');
  9. preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
  10. if (!(isset($matches[0]) && $matches[1] >= 12)) {
  11. die("skip expected output only valid when using Oracle Database 12c or greater");
  12. }
  13. preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
  14. if (!(isset($matches[0]) && $matches[0] >= 12)) {
  15. die("skip works only with Oracle 12c or greater version of Oracle client libraries");
  16. }
  17. ?>
  18. --FILE--
  19. <?php
  20. require(__DIR__.'/connect.inc');
  21. // Initialization
  22. $stmtarray = array(
  23. "drop table imp_res_6_tab",
  24. "create table imp_res_6_tab (c1 number, c2 varchar2(10))",
  25. "insert into imp_res_6_tab values (1, 'a')",
  26. "insert into imp_res_6_tab values (2, 'b')",
  27. "insert into imp_res_6_tab values (3, 'c')",
  28. "insert into imp_res_6_tab values (4, 'd')",
  29. "insert into imp_res_6_tab values (5, 'e')",
  30. "insert into imp_res_6_tab values (6, 'f')",
  31. "create or replace procedure imp_res_6_proc as
  32. c1 sys_refcursor;
  33. begin
  34. open c1 for select * from imp_res_6_tab order by 1;
  35. dbms_sql.return_result(c1);
  36. end;"
  37. );
  38. oci8_test_sql_execute($c, $stmtarray);
  39. // Run Test
  40. echo "Test 1\n";
  41. $s = oci_parse($c, "begin imp_res_6_proc(); end;");
  42. oci_execute($s);
  43. $row = oci_fetch_assoc($s);
  44. var_dump($row);
  45. $row = oci_fetch_row($s);
  46. var_dump($row);
  47. $row = oci_fetch_object($s);
  48. var_dump($row);
  49. $row = oci_fetch_array($s);
  50. var_dump($row);
  51. $row = oci_fetch_array($s, OCI_NUM);
  52. var_dump($row);
  53. $row = oci_fetch_array($s, OCI_ASSOC);
  54. var_dump($row);
  55. // Clean up
  56. $stmtarray = array(
  57. "drop procedure imp_res_6_proc",
  58. "drop table imp_res_6_tab",
  59. );
  60. oci8_test_sql_execute($c, $stmtarray);
  61. ?>
  62. --EXPECTF--
  63. Test 1
  64. array(2) {
  65. ["C1"]=>
  66. string(1) "1"
  67. ["C2"]=>
  68. string(1) "a"
  69. }
  70. array(2) {
  71. [0]=>
  72. string(1) "2"
  73. [1]=>
  74. string(1) "b"
  75. }
  76. object(stdClass)#%d (2) {
  77. ["C1"]=>
  78. string(1) "3"
  79. ["C2"]=>
  80. string(1) "c"
  81. }
  82. array(4) {
  83. [0]=>
  84. string(1) "4"
  85. ["C1"]=>
  86. string(1) "4"
  87. [1]=>
  88. string(1) "d"
  89. ["C2"]=>
  90. string(1) "d"
  91. }
  92. array(2) {
  93. [0]=>
  94. string(1) "5"
  95. [1]=>
  96. string(1) "e"
  97. }
  98. array(2) {
  99. ["C1"]=>
  100. string(1) "6"
  101. ["C2"]=>
  102. string(1) "f"
  103. }