xref: /PHP-8.1/ext/oci8/tests/fetch_all4.phpt (revision 74859783)
1--TEST--
2Test oci_fetch_* array overwriting when query returns no rows
3--EXTENSIONS--
4oci8
5--FILE--
6<?php
7
8require(__DIR__.'/connect.inc');
9
10// Initialization
11
12$stmtarray = array(
13    "drop table fetch_all4_tab",
14    "create table fetch_all4_tab (mycol1 number, mycol2 varchar2(20))",
15    "insert into fetch_all4_tab values (1, 'abc')"
16);
17
18oci8_test_sql_execute($c, $stmtarray);
19
20// Run Test
21
22echo "Test 1\n";
23
24$s = oci_parse($c, "select * from fetch_all4_tab where 1 = 0");
25oci_execute($s);
26$res = array(1,2,3);  // this array is replaced as a result of the query
27$r = oci_fetch_all($s, $res);
28var_dump($r);
29var_dump($res);
30
31echo "Test 2\n";
32
33$s = oci_parse($c, "select * from fetch_all4_tab where 1 = 0");
34oci_execute($s);
35$row = array(1,2,3);  // this array is replaced as a result of the query
36$row = oci_fetch_array($s);
37var_dump($row);
38
39// Clean up
40
41$stmtarray = array(
42    "drop table fetch_all4_tab"
43);
44
45oci8_test_sql_execute($c, $stmtarray);
46
47?>
48--EXPECT--
49Test 1
50int(0)
51array(2) {
52  ["MYCOL1"]=>
53  array(0) {
54  }
55  ["MYCOL2"]=>
56  array(0) {
57  }
58}
59Test 2
60bool(false)
61