xref: /PHP-5.5/ext/oci8/tests/fetch_all5.phpt (revision c7a8bd6a)
1--TEST--
2Test oci_fetch_all with 0 and -1 skip & maxrows
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_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===DONE===
60<?php exit(0); ?>
61--EXPECTF--
62Test 1
63int(3)
64array(2) {
65  [%u|b%"MYCOL1"]=>
66  array(3) {
67    [0]=>
68    %unicode|string%(1) "1"
69    [1]=>
70    %unicode|string%(1) "2"
71    [2]=>
72    %unicode|string%(1) "3"
73  }
74  [%u|b%"MYCOL2"]=>
75  array(3) {
76    [0]=>
77    %unicode|string%(3) "abc"
78    [1]=>
79    %unicode|string%(3) "def"
80    [2]=>
81    %unicode|string%(3) "ghi"
82  }
83}
84Test 1
85int(3)
86array(2) {
87  [%u|b%"MYCOL1"]=>
88  array(3) {
89    [0]=>
90    %unicode|string%(1) "1"
91    [1]=>
92    %unicode|string%(1) "2"
93    [2]=>
94    %unicode|string%(1) "3"
95  }
96  [%u|b%"MYCOL2"]=>
97  array(3) {
98    [0]=>
99    %unicode|string%(3) "abc"
100    [1]=>
101    %unicode|string%(3) "def"
102    [2]=>
103    %unicode|string%(3) "ghi"
104  }
105}
106Test 3
107int(0)
108array(0) {
109}
110===DONE===
111