xref: /PHP-7.2/ext/oci8/tests/lob_002.phpt (revision 3d497f88)
1--TEST--
2oci_lob_write() and friends (with errors)
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_002_tab",
17	"create table lob_002_tab (id number, b1 BLOB)",
18);
19
20oci8_test_sql_execute($c, $stmtarray);
21
22$statement = oci_parse($c, "insert into lob_002_tab (id, b1) values (1, empty_blob()) returning b1 INTO :v_blob ");
23$blob = oci_new_descriptor($c,OCI_D_LOB);
24oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
25oci_execute($statement, OCI_DEFAULT);
26
27var_dump($blob);
28
29var_dump($blob->write("test", -1));
30var_dump($blob->write("test", "str"));
31var_dump($blob->write("test", 1000000));
32var_dump($blob->write(str_repeat("test", 10000), 1000000));
33var_dump($blob->tell());
34var_dump($blob->seek("str", -5));
35var_dump($blob->flush());
36
37oci_commit($c);
38
39$select_sql = "select b1 from lob_002_tab where id = 1";
40$s = oci_parse($c, $select_sql);
41oci_execute($s);
42
43$row = oci_fetch_array($s, OCI_RETURN_LOBS);
44
45var_dump(strlen($row[0]));
46
47// Cleanup
48
49$stmtarray = array(
50	"drop table lob_002_tab"
51);
52
53oci8_test_sql_execute($c, $stmtarray);
54
55?>
56===DONE===
57<?php exit(0); ?>
58--EXPECTF--
59object(OCI-Lob)#%d (1) {
60  ["descriptor"]=>
61  resource(%d) of type (oci8 descriptor)
62}
63int(0)
64
65Warning: OCI-Lob::write() expects parameter 2 to be int%s string given in %slob_002.php on line %d
66NULL
67int(4)
68int(40000)
69int(40004)
70
71Warning: OCI-Lob::seek() expects parameter 1 to be int%s string given in %slob_002.php on line %d
72NULL
73bool(false)
74int(40004)
75===DONE===
76