Annotation of embedaddon/php/ext/oci8/tests/lob_001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: oci_lob_write() and friends
3: --SKIPIF--
4: <?php
5: $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
6: require(dirname(__FILE__).'/skipif.inc');
7: ?>
8: --FILE--
9: <?php
10:
11: require(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:
20: oci8_test_sql_execute($c, $stmtarray);
21:
22: echo "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);
26: var_dump(oci_bind_by_name($statement, ":v_b1", $blob, -1, OCI_B_BLOB));
27: oci_execute($statement, OCI_DEFAULT);
28: var_dump($blob);
29:
30: echo "Test 2\n";
31:
32: var_dump($blob->write("test"));
33: var_dump($blob->tell());
34: var_dump($blob->seek(10, OCI_SEEK_CUR));
35: var_dump($blob->write("string"));
36: var_dump($blob->flush());
37:
38: oci_commit($c);
39:
40: echo "Test 3\n";
41:
42: $s = oci_parse($c, "select b1 from lob_001_tab where id = 1");
43: oci_execute($s);
44: var_dump(oci_fetch_array($s, OCI_RETURN_LOBS));
45:
46: echo "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);
50: var_dump(oci_bind_by_name($statement, ":v_b1", $blob, -1, SQLT_BLOB));
51: oci_execute($statement, OCI_DEFAULT);
52: var_dump($blob->write("test row 2"));
53:
54: $s = oci_parse($c, "select b1 from lob_001_tab where id = 2");
55: oci_execute($s);
56: var_dump(oci_fetch_array($s, OCI_RETURN_LOBS));
57:
58: // Cleanup
59:
60: $stmtarray = array(
61: "drop table lob_001_tab"
62: );
63:
64: oci8_test_sql_execute($c, $stmtarray);
65:
66: ?>
67: ===DONE===
68: <?php exit(0); ?>
69: --EXPECTF--
70: Test 1 OCI_B_BLOB bind
71: bool(true)
72: object(OCI-Lob)#%d (1) {
73: ["descriptor"]=>
74: resource(%d) of type (oci8 descriptor)
75: }
76: Test 2
77: int(4)
78: int(4)
79: bool(true)
80: int(6)
81: bool(false)
82: Test 3
83: array(2) {
84: [0]=>
85: string(20) "test string"
86: ["B1"]=>
87: string(20) "test string"
88: }
89: Test 4 SQLT_BLOB (an alias for OCI_B_BLOB) bind
90: bool(true)
91: int(10)
92: array(2) {
93: [0]=>
94: string(10) "test row 2"
95: ["B1"]=>
96: string(10) "test row 2"
97: }
98: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>