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