xref: /PHP-8.3/ext/oci8/tests/fetch_all5.phpt (revision a53e5617)
1--TEST--
2Test oci_fetch_all with 0 and -1 skip & maxrows
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_all5_tab",
18    "create table fetch_all5_tab (mycol1 number, mycol2 varchar2(20))",
19    "insert into fetch_all5_tab values (1, 'abc')",
20    "insert into fetch_all5_tab values (2, 'def')",
21    "insert into fetch_all5_tab values (3, 'ghi')"
22);
23
24oci8_test_sql_execute($c, $stmtarray);
25
26// Run Test
27
28echo "Test 1\n";
29
30$s = oci_parse($c, "select * from fetch_all5_tab order by 1");
31oci_execute($s);
32$r = oci_fetch_all($s, $res, 0, -1);
33var_dump($r);
34var_dump($res);
35
36echo "Test 1\n";
37
38$s = oci_parse($c, "select * from fetch_all5_tab order by 1");
39oci_execute($s);
40$r = oci_fetch_all($s, $res, 0, 0);
41var_dump($r);
42var_dump($res);
43
44echo "Test 3\n";
45
46$s = oci_parse($c, "select * from fetch_all5_tab order by 1");
47oci_execute($s);
48$r = oci_fetch_all($s, $res, -1, 0);
49var_dump($r);
50var_dump($res);
51
52// Clean up
53
54$stmtarray = array(
55    "drop table fetch_all5_tab"
56);
57
58oci8_test_sql_execute($c, $stmtarray);
59
60oci_close($c);
61
62?>
63--EXPECT--
64Test 1
65int(3)
66array(2) {
67  ["MYCOL1"]=>
68  array(3) {
69    [0]=>
70    string(1) "1"
71    [1]=>
72    string(1) "2"
73    [2]=>
74    string(1) "3"
75  }
76  ["MYCOL2"]=>
77  array(3) {
78    [0]=>
79    string(3) "abc"
80    [1]=>
81    string(3) "def"
82    [2]=>
83    string(3) "ghi"
84  }
85}
86Test 1
87int(3)
88array(2) {
89  ["MYCOL1"]=>
90  array(3) {
91    [0]=>
92    string(1) "1"
93    [1]=>
94    string(1) "2"
95    [2]=>
96    string(1) "3"
97  }
98  ["MYCOL2"]=>
99  array(3) {
100    [0]=>
101    string(3) "abc"
102    [1]=>
103    string(3) "def"
104    [2]=>
105    string(3) "ghi"
106  }
107}
108Test 3
109int(0)
110array(0) {
111}
112