xref: /PHP-5.5/ext/oci8/tests/fetch_object.phpt (revision c7a8bd6a)
1--TEST--
2oci_fetch_object()
3--SKIPIF--
4<?php
5$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
6require(dirname(__FILE__).'/skipif.inc');
7?>
8--FILE--
9<?php
10
11require(dirname(__FILE__).'/connect.inc');
12
13// Initialization
14
15$stmtarray = array(
16    "drop table fetch_object_tab",
17    "create table fetch_object_tab (\"caseSensitive\" number, secondcol varchar2(20), anothercol char(15))",
18    "insert into fetch_object_tab values (123, '1st row col2 string', '1 more text')",
19    "insert into fetch_object_tab values (456, '2nd row col2 string', '2 more text')",
20    "insert into fetch_object_tab values (789, '3rd row col2 string', '3 more text')",
21);
22
23oci8_test_sql_execute($c, $stmtarray);
24
25// Run Test
26
27echo "Test 1\n";
28
29if (!($s = oci_parse($c, 'select * from fetch_object_tab'))) {
30    die("oci_parse(select) failed!\n");
31}
32
33if (!oci_execute($s)) {
34    die("oci_execute(select) failed!\n");
35}
36
37while ($row = oci_fetch_object($s)) {
38    var_dump($row);
39}
40
41echo "Test 2\n";
42
43if (!($s = oci_parse($c, 'select * from fetch_object_tab'))) {
44    die("oci_parse(select) failed!\n");
45}
46
47if (!oci_execute($s)) {
48    die("oci_execute(select) failed!\n");
49}
50
51while ($row = oci_fetch_object($s)) {
52    echo $row->caseSensitive . "\n";
53    echo $row->SECONDCOL . "\n";
54    echo $row->ANOTHERCOL . "\n";
55}
56
57echo "Test 3\n";
58
59if (!($s = oci_parse($c, 'select * from fetch_object_tab where rownum < 2 order by "caseSensitive"'))) {
60    die("oci_parse(select) failed!\n");
61}
62
63if (!oci_execute($s)) {
64    die("oci_execute(select) failed!\n");
65}
66
67$row = oci_fetch_object($s);
68echo $row->caseSensitive . "\n";
69echo $row->CASESENSITIVE . "\n";
70
71// Clean up
72
73$stmtarray = array(
74    "drop table fetch_object_tab"
75);
76
77oci8_test_sql_execute($c, $stmtarray);
78
79?>
80===DONE===
81<?php exit(0); ?>
82--EXPECTF--
83Test 1
84object(stdClass)#1 (3) {
85  [%u|b%"caseSensitive"]=>
86  %unicode|string%(3) "123"
87  [%u|b%"SECONDCOL"]=>
88  %unicode|string%(19) "1st row col2 string"
89  [%u|b%"ANOTHERCOL"]=>
90  %unicode|string%(15) "1 more text    "
91}
92object(stdClass)#2 (3) {
93  [%u|b%"caseSensitive"]=>
94  %unicode|string%(3) "456"
95  [%u|b%"SECONDCOL"]=>
96  %unicode|string%(19) "2nd row col2 string"
97  [%u|b%"ANOTHERCOL"]=>
98  %unicode|string%(15) "2 more text    "
99}
100object(stdClass)#1 (3) {
101  [%u|b%"caseSensitive"]=>
102  %unicode|string%(3) "789"
103  [%u|b%"SECONDCOL"]=>
104  %unicode|string%(19) "3rd row col2 string"
105  [%u|b%"ANOTHERCOL"]=>
106  %unicode|string%(15) "3 more text    "
107}
108Test 2
109123
1101st row col2 string
1111 more text
112456
1132nd row col2 string
1142 more text
115789
1163rd row col2 string
1173 more text
118Test 3
119123
120
121Notice: Undefined property: stdClass::$CASESENSITIVE in %sfetch_object.php on line %d
122
123===DONE===
124