xref: /PHP-5.5/ext/oci8/tests/fetch_object_2.phpt (revision c7a8bd6a)
1--TEST--
2oci_fetch_object() with CLOB and NULL
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_2_tab",
17    "create table fetch_object_2_tab (col1 number, col2 CLOB, col3 varchar2(15))",
18    "insert into fetch_object_2_tab values (123, '1st row col2 string', '1 more text')",
19    "insert into fetch_object_2_tab values (456, '2nd row col2 string', NULL)",
20    "insert into fetch_object_2_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_2_tab order by 1'))) {
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_2_tab order by 1'))) {
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->COL1 . "\n";
53    echo $row->COL2->load(100) . "\n";
54    echo $row->COL3 . "\n";
55}
56
57// Clean up
58
59$stmtarray = array(
60    "drop table fetch_object_2_tab"
61);
62
63oci8_test_sql_execute($c, $stmtarray);
64
65?>
66===DONE===
67<?php exit(0); ?>
68--EXPECTF--
69Test 1
70object(stdClass)#%d (3) {
71  ["COL1"]=>
72  string(3) "123"
73  ["COL2"]=>
74  object(OCI-Lob)#%d (1) {
75    ["descriptor"]=>
76    resource(%d) of type (oci8 descriptor)
77  }
78  ["COL3"]=>
79  string(11) "1 more text"
80}
81object(stdClass)#%d (3) {
82  ["COL1"]=>
83  string(3) "456"
84  ["COL2"]=>
85  object(OCI-Lob)#%d (1) {
86    ["descriptor"]=>
87    resource(%d) of type (oci8 descriptor)
88  }
89  ["COL3"]=>
90  NULL
91}
92object(stdClass)#%d (3) {
93  ["COL1"]=>
94  string(3) "789"
95  ["COL2"]=>
96  object(OCI-Lob)#%d (1) {
97    ["descriptor"]=>
98    resource(%d) of type (oci8 descriptor)
99  }
100  ["COL3"]=>
101  string(11) "3 more text"
102}
103Test 2
104123
1051st row col2 string
1061 more text
107456
1082nd row col2 string
109
110789
1113rd row col2 string
1123 more text
113===DONE===
114