xref: /PHP-5.4/ext/oci8/tests/lob_001.phpt (revision c7a8bd6a)
1--TEST--
2oci_lob_write() and friends
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 lob_001_tab",
17	"create table lob_001_tab (id number, b1 blob)",
18);
19
20oci8_test_sql_execute($c, $stmtarray);
21
22echo "Test 1 OCI_B_BLOB bind\n";
23
24$statement = oci_parse($c, "insert into lob_001_tab (id, b1) values (1, empty_blob()) returning b1 into :v_b1 ");
25$blob = oci_new_descriptor($c,OCI_D_LOB);
26var_dump(oci_bind_by_name($statement, ":v_b1", $blob, -1, OCI_B_BLOB));
27oci_execute($statement, OCI_DEFAULT);
28var_dump($blob);
29
30echo "Test 2\n";
31
32var_dump($blob->write("test"));
33var_dump($blob->tell());
34var_dump($blob->seek(10, OCI_SEEK_CUR));
35var_dump($blob->write("string"));
36var_dump($blob->flush());
37
38oci_commit($c);
39
40echo "Test 3\n";
41
42$s = oci_parse($c, "select b1 from lob_001_tab where id = 1");
43oci_execute($s);
44var_dump(oci_fetch_array($s, OCI_RETURN_LOBS));
45
46echo "Test 4 SQLT_BLOB (an alias for OCI_B_BLOB) bind\n";
47
48$statement = oci_parse($c, "insert into lob_001_tab (id, b1) values (2, empty_blob()) returning b1 into :v_b1 ");
49$blob = oci_new_descriptor($c,OCI_D_LOB);
50var_dump(oci_bind_by_name($statement, ":v_b1", $blob, -1, SQLT_BLOB));
51oci_execute($statement, OCI_DEFAULT);
52var_dump($blob->write("test row 2"));
53
54$s = oci_parse($c, "select b1 from lob_001_tab where id = 2");
55oci_execute($s);
56var_dump(oci_fetch_array($s, OCI_RETURN_LOBS));
57
58// Cleanup
59
60$stmtarray = array(
61	"drop table lob_001_tab"
62);
63
64oci8_test_sql_execute($c, $stmtarray);
65
66?>
67===DONE===
68<?php exit(0); ?>
69--EXPECTF--
70Test 1 OCI_B_BLOB bind
71bool(true)
72object(OCI-Lob)#%d (1) {
73  ["descriptor"]=>
74  resource(%d) of type (oci8 descriptor)
75}
76Test 2
77int(4)
78int(4)
79bool(true)
80int(6)
81bool(false)
82Test 3
83array(2) {
84  [0]=>
85  string(20) "test����������string"
86  ["B1"]=>
87  string(20) "test����������string"
88}
89Test 4 SQLT_BLOB (an alias for OCI_B_BLOB) bind
90bool(true)
91int(10)
92array(2) {
93  [0]=>
94  string(10) "test row 2"
95  ["B1"]=>
96  string(10) "test row 2"
97}
98===DONE===
99