xref: /PHP-5.6/ext/oci8/tests/lob_038.phpt (revision c7a8bd6a)
1--TEST--
2Array fetch CLOB and BLOB
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';
12require dirname(__FILE__).'/create_table.inc';
13
14echo "Test 1: CLOB\n";
15
16$ora_sql = "INSERT INTO
17                       ".$schema.$table_name." (clob)
18                      VALUES (empty_clob())
19                      RETURNING
20                               clob
21                      INTO :v_clob ";
22
23$s = oci_parse($c,$ora_sql);
24$clob = oci_new_descriptor($c,OCI_DTYPE_LOB);
25
26
27oci_bind_by_name($s,":v_clob", $clob,-1,OCI_B_CLOB);
28
29oci_execute($s, OCI_DEFAULT);
30var_dump($clob->save("clob test 1"));
31
32oci_execute($s, OCI_DEFAULT);
33var_dump($clob->save("clob test 2"));
34
35oci_execute($s, OCI_DEFAULT);
36var_dump($clob->save("clob test 3"));
37
38
39$s = oci_parse($c,"select clob from ".$schema.$table_name);
40var_dump(oci_execute($s));
41
42oci_fetch_all($s, $res);
43
44var_dump($res);
45
46
47echo "Test 1b\n";
48
49$s = oci_parse($c, "select clob from ".$schema.$table_name);
50var_dump(oci_execute($s, OCI_DEFAULT));
51while ($row = oci_fetch_array($s, OCI_ASSOC)) {
52    var_dump($row);
53    $result = $row['CLOB']->load();
54    var_dump($result);
55}
56
57
58require dirname(__FILE__).'/drop_table.inc';
59
60echo "Test 2: BLOB\n";
61
62require dirname(__FILE__).'/create_table.inc';
63
64$ora_sql = "INSERT INTO
65                       ".$schema.$table_name." (blob)
66                      VALUES (empty_blob())
67                      RETURNING
68                               blob
69                      INTO :v_blob ";
70
71$s = oci_parse($c,$ora_sql);
72$blob = oci_new_descriptor($c,OCI_DTYPE_LOB);
73
74
75oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
76
77oci_execute($s, OCI_DEFAULT);
78var_dump($blob->save("blob test 1"));
79
80oci_execute($s, OCI_DEFAULT);
81var_dump($blob->save("blob test 2"));
82
83oci_execute($s, OCI_DEFAULT);
84var_dump($blob->save("blob test 3"));
85
86$s = oci_parse($c, "select blob from ".$schema.$table_name);
87var_dump(oci_execute($s));
88oci_fetch_all($s, $res);
89var_dump($res);
90
91echo "Test 2b\n";
92
93$s = oci_parse($c, "select blob from ".$schema.$table_name);
94var_dump(oci_execute($s, OCI_DEFAULT));
95while ($row = oci_fetch_array($s, OCI_ASSOC)) {
96    var_dump($row);
97    $result = $row['BLOB']->load();
98    var_dump($result);
99}
100
101
102require dirname(__FILE__).'/drop_table.inc';
103
104echo "Done\n";
105
106?>
107--EXPECTF--
108Test 1: CLOB
109bool(true)
110bool(true)
111bool(true)
112bool(true)
113array(1) {
114  ["CLOB"]=>
115  array(3) {
116    [0]=>
117    string(11) "clob test 1"
118    [1]=>
119    string(11) "clob test 2"
120    [2]=>
121    string(11) "clob test 3"
122  }
123}
124Test 1b
125bool(true)
126array(1) {
127  ["CLOB"]=>
128  object(OCI-Lob)#2 (1) {
129    ["descriptor"]=>
130    resource(%d) of type (oci8 descriptor)
131  }
132}
133string(11) "clob test 1"
134array(1) {
135  ["CLOB"]=>
136  object(OCI-Lob)#3 (1) {
137    ["descriptor"]=>
138    resource(%d) of type (oci8 descriptor)
139  }
140}
141string(11) "clob test 2"
142array(1) {
143  ["CLOB"]=>
144  object(OCI-Lob)#2 (1) {
145    ["descriptor"]=>
146    resource(%d) of type (oci8 descriptor)
147  }
148}
149string(11) "clob test 3"
150Test 2: BLOB
151bool(true)
152bool(true)
153bool(true)
154bool(true)
155array(1) {
156  ["BLOB"]=>
157  array(3) {
158    [0]=>
159    string(11) "blob test 1"
160    [1]=>
161    string(11) "blob test 2"
162    [2]=>
163    string(11) "blob test 3"
164  }
165}
166Test 2b
167bool(true)
168array(1) {
169  ["BLOB"]=>
170  object(OCI-Lob)#3 (1) {
171    ["descriptor"]=>
172    resource(%d) of type (oci8 descriptor)
173  }
174}
175string(11) "blob test 1"
176array(1) {
177  ["BLOB"]=>
178  object(OCI-Lob)#4 (1) {
179    ["descriptor"]=>
180    resource(%d) of type (oci8 descriptor)
181  }
182}
183string(11) "blob test 2"
184array(1) {
185  ["BLOB"]=>
186  object(OCI-Lob)#3 (1) {
187    ["descriptor"]=>
188    resource(%d) of type (oci8 descriptor)
189  }
190}
191string(11) "blob test 3"
192Done