1--TEST-- 2bind and fetch cursor from a statement 3--SKIPIF-- 4<?php 5$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs 6require(__DIR__.'/skipif.inc'); 7?> 8--FILE-- 9<?php 10 11require(__DIR__."/connect.inc"); 12 13// Initialization 14 15$stmtarray = array( 16 "drop table cursor_bind_tab", 17 "create table cursor_bind_tab (id NUMBER, value VARCHAR(20))", 18 "insert into cursor_bind_tab values (1, '1')", 19 "insert into cursor_bind_tab values (1, '1')", 20 "insert into cursor_bind_tab values (1, '1')" 21); 22 23oci8_test_sql_execute($c, $stmtarray); 24 25$sql = " 26DECLARE 27TYPE curtype IS REF CURSOR; 28cursor_var curtype; 29BEGIN 30 OPEN cursor_var FOR SELECT id, value FROM cursor_bind_tab; 31 :curs := cursor_var; 32END; 33"; 34 35$stmt = oci_parse($c, $sql); 36 37$cursor = oci_new_cursor($c); 38oci_bind_by_name($stmt, ":curs", $cursor, -1, OCI_B_CURSOR); 39 40oci_execute($stmt); 41 42oci_execute($cursor); 43var_dump(oci_fetch_row($cursor)); 44var_dump(oci_fetch_row($cursor)); 45var_dump(oci_fetch_row($cursor)); 46var_dump(oci_fetch_row($cursor)); 47 48// Clean up 49 50$stmtarray = array( 51 "drop table cursor_bind_tab" 52); 53 54oci8_test_sql_execute($c, $stmtarray); 55 56?> 57--EXPECT-- 58array(2) { 59 [0]=> 60 string(1) "1" 61 [1]=> 62 string(1) "1" 63} 64array(2) { 65 [0]=> 66 string(1) "1" 67 [1]=> 68 string(1) "1" 69} 70array(2) { 71 [0]=> 72 string(1) "1" 73 [1]=> 74 string(1) "1" 75} 76bool(false) 77