xref: /PHP-7.2/ext/oci8/tests/fetch_all4.phpt (revision bdd67d81)
1--TEST--
2Test oci_fetch_* array overwriting when query returns no rows
3--SKIPIF--
4<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
5--FILE--
6<?php
7
8require(dirname(__FILE__).'/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===DONE===
49<?php exit(0); ?>
50--EXPECT--
51Test 1
52int(0)
53array(2) {
54  ["MYCOL1"]=>
55  array(0) {
56  }
57  ["MYCOL2"]=>
58  array(0) {
59  }
60}
61Test 2
62bool(false)
63===DONE===
64