1--TEST-- 2Oracle Database 12c Implicit Result Sets: basic test 3--EXTENSIONS-- 4oci8 5--SKIPIF-- 6<?php 7require_once 'skipifconnectfailure.inc'; 8$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs 9require __DIR__.'/skipif.inc'; 10preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); 11if (!(isset($matches[0]) && $matches[1] >= 12)) { 12 die("skip expected output only valid when using Oracle Database 12c or greater"); 13} 14preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); 15if (!(isset($matches[0]) && $matches[0] >= 12)) { 16 die("skip works only with Oracle 12c or greater version of Oracle client libraries"); 17} 18?> 19--FILE-- 20<?php 21 22require __DIR__.'/connect.inc'; 23 24// Initialization 25 26$stmtarray = array( 27 "drop table imp_res_prefetch_tab_1", 28 "create table imp_res_prefetch_tab_1 (c1 number, c2 varchar2(10))", 29 "insert into imp_res_prefetch_tab_1 values (1, 'abcde')", 30 "insert into imp_res_prefetch_tab_1 values (2, 'fghij')", 31 "insert into imp_res_prefetch_tab_1 values (3, 'klmno')", 32 33 "drop table imp_res_prefetch_tab_2", 34 "create table imp_res_prefetch_tab_2 (c3 varchar2(1))", 35 "insert into imp_res_prefetch_tab_2 values ('t')", 36 "insert into imp_res_prefetch_tab_2 values ('u')", 37 "insert into imp_res_prefetch_tab_2 values ('v')", 38 39 "create or replace procedure imp_res_prefetch_proc as 40 c1 sys_refcursor; 41 begin 42 open c1 for select * from imp_res_prefetch_tab_1 order by 1; 43 dbms_sql.return_result(c1); 44 45 open c1 for select * from imp_res_prefetch_tab_2 order by 1; 46 dbms_sql.return_result(c1); 47 end;" 48); 49 50oci8_test_sql_execute($c, $stmtarray); 51 52// Run Test 53 54echo "Test 1 - prefetch 0\n"; 55$s = oci_parse($c, "begin imp_res_prefetch_proc(); end;"); 56oci_execute($s); 57var_dump(oci_set_prefetch($s, 0)); 58while (($row = oci_fetch_row($s)) != false) 59 var_dump($row); 60 61echo "\nTest 1 - prefetch 1\n"; 62$s = oci_parse($c, "begin imp_res_prefetch_proc(); end;"); 63oci_execute($s); 64var_dump(oci_set_prefetch($s, 1)); 65while (($row = oci_fetch_row($s)) != false) 66 var_dump($row); 67 68echo "\nTest 1 - prefetch 2\n"; 69$s = oci_parse($c, "begin imp_res_prefetch_proc(); end;"); 70oci_execute($s); 71var_dump(oci_set_prefetch($s, 2)); 72while (($row = oci_fetch_row($s)) != false) 73 var_dump($row); 74 75// Clean up 76 77$stmtarray = array( 78 "drop procedure imp_res_prefetch_proc", 79 "drop table imp_res_prefetch_tab_1", 80 "drop table imp_res_prefetch_tab_2" 81); 82 83oci8_test_sql_execute($c, $stmtarray); 84 85?> 86--EXPECT-- 87Test 1 - prefetch 0 88bool(true) 89array(2) { 90 [0]=> 91 string(1) "1" 92 [1]=> 93 string(5) "abcde" 94} 95array(2) { 96 [0]=> 97 string(1) "2" 98 [1]=> 99 string(5) "fghij" 100} 101array(2) { 102 [0]=> 103 string(1) "3" 104 [1]=> 105 string(5) "klmno" 106} 107array(1) { 108 [0]=> 109 string(1) "t" 110} 111array(1) { 112 [0]=> 113 string(1) "u" 114} 115array(1) { 116 [0]=> 117 string(1) "v" 118} 119 120Test 1 - prefetch 1 121bool(true) 122array(2) { 123 [0]=> 124 string(1) "1" 125 [1]=> 126 string(5) "abcde" 127} 128array(2) { 129 [0]=> 130 string(1) "2" 131 [1]=> 132 string(5) "fghij" 133} 134array(2) { 135 [0]=> 136 string(1) "3" 137 [1]=> 138 string(5) "klmno" 139} 140array(1) { 141 [0]=> 142 string(1) "t" 143} 144array(1) { 145 [0]=> 146 string(1) "u" 147} 148array(1) { 149 [0]=> 150 string(1) "v" 151} 152 153Test 1 - prefetch 2 154bool(true) 155array(2) { 156 [0]=> 157 string(1) "1" 158 [1]=> 159 string(5) "abcde" 160} 161array(2) { 162 [0]=> 163 string(1) "2" 164 [1]=> 165 string(5) "fghij" 166} 167array(2) { 168 [0]=> 169 string(1) "3" 170 [1]=> 171 string(5) "klmno" 172} 173array(1) { 174 [0]=> 175 string(1) "t" 176} 177array(1) { 178 [0]=> 179 string(1) "u" 180} 181array(1) { 182 [0]=> 183 string(1) "v" 184} 185