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