xref: /PHP-7.3/ext/oci8/tests/lob_003.phpt (revision 37652336)
1--TEST--
2oci_lob_read() 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';
12require dirname(__FILE__).'/create_table.inc';
13
14$ora_sql = "INSERT INTO
15                       ".$schema.$table_name." (blob)
16                      VALUES (empty_blob())
17                      RETURNING
18                               blob
19                      INTO :v_blob ";
20
21$statement = oci_parse($c,$ora_sql);
22$blob = oci_new_descriptor($c,OCI_D_LOB);
23oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
24oci_execute($statement, OCI_DEFAULT);
25
26var_dump($blob);
27
28var_dump($blob->write("test"));
29var_dump($blob->tell());
30var_dump($blob->seek(10, OCI_SEEK_CUR));
31var_dump($blob->write("string"));
32var_dump($blob->flush());
33
34oci_commit($c);
35
36$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
37$s = oci_parse($c, $select_sql);
38oci_execute($s, OCI_DEFAULT);
39
40var_dump($row = oci_fetch_array($s));
41
42var_dump($row[0]->read(-1));
43var_dump($row[0]->read(10000));
44
45require dirname(__FILE__).'/drop_table.inc';
46
47echo "Done\n";
48
49?>
50--EXPECTF--
51object(OCI-Lob)#%d (1) {
52  ["descriptor"]=>
53  resource(%d) of type (oci8 descriptor)
54}
55int(4)
56int(4)
57bool(true)
58int(6)
59bool(false)
60array(2) {
61  [0]=>
62  object(OCI-Lob)#%d (1) {
63    ["descriptor"]=>
64    resource(%d) of type (oci8 descriptor)
65  }
66  ["BLOB"]=>
67  object(OCI-Lob)#%d (1) {
68    ["descriptor"]=>
69    resource(%d) of type (oci8 descriptor)
70  }
71}
72
73Warning: OCI-Lob::read(): Length parameter must be greater than 0 in %s on line %d
74bool(false)
75string(20) "test����������string"
76Done
77