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