xref: /PHP-8.1/ext/oci8/tests/lob_002.phpt (revision b5a14e6c)
1--TEST--
2oci_lob_write() and friends (with errors)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
8require(__DIR__.'/skipif.inc');
9?>
10--FILE--
11<?php
12
13require(__DIR__.'/connect.inc');
14
15// Initialization
16
17$stmtarray = array(
18    "drop table lob_002_tab",
19    "create table lob_002_tab (id number, b1 BLOB)",
20);
21
22oci8_test_sql_execute($c, $stmtarray);
23
24$statement = oci_parse($c, "insert into lob_002_tab (id, b1) values (1, empty_blob()) returning b1 INTO :v_blob ");
25$blob = oci_new_descriptor($c,OCI_D_LOB);
26oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
27oci_execute($statement, OCI_DEFAULT);
28
29var_dump($blob);
30
31var_dump($blob->write("test", -1));
32var_dump($blob->write("test", 1000000));
33var_dump($blob->write(str_repeat("test", 10000), 1000000));
34var_dump($blob->tell());
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--EXPECTF--
57object(OCILob)#%d (1) {
58  ["descriptor"]=>
59  resource(%d) of type (oci8 descriptor)
60}
61int(0)
62int(4)
63int(40000)
64int(40004)
65bool(false)
66int(40004)
67