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