xref: /PHP-8.1/ext/oci8/tests/lob_006.phpt (revision b5a14e6c)
1--TEST--
2oci_lob_write()/truncate()/erase()
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');
14require(__DIR__.'/create_table.inc');
15
16$ora_sql = "INSERT INTO
17                       ".$schema.$table_name." (blob)
18                      VALUES (empty_blob())
19                      RETURNING
20                               blob
21                      INTO :v_blob ";
22
23$statement = oci_parse($c,$ora_sql);
24$blob = oci_new_descriptor($c,OCI_D_LOB);
25oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
26oci_execute($statement, OCI_DEFAULT);
27
28var_dump($blob);
29
30$str = "this is a biiiig faaat test string. why are you reading it, I wonder? =)";
31var_dump($blob->write($str));
32var_dump($blob->truncate());
33var_dump($blob->seek(0, OCI_SEEK_SET));
34var_dump($blob->write("string was here. tick-tack-tick-tack."));
35var_dump($blob->erase(10, 10));
36var_dump($blob->write("some"));
37
38oci_commit($c);
39
40$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
41$s = oci_parse($c, $select_sql);
42oci_execute($s, OCI_DEFAULT);
43
44var_dump($row = oci_fetch_array($s));
45
46var_dump($row[0]->read(10000));
47
48require __DIR__.'/drop_table.inc';
49
50echo "Done\n";
51
52?>
53--EXPECTF--
54object(OCILob)#%d (1) {
55  ["descriptor"]=>
56  resource(%d) of type (oci8 descriptor)
57}
58int(72)
59bool(true)
60bool(true)
61int(37)
62int(10)
63int(4)
64array(2) {
65  [0]=>
66  object(OCILob)#%d (1) {
67    ["descriptor"]=>
68    resource(%d) of type (oci8 descriptor)
69  }
70  ["BLOB"]=>
71  object(OCILob)#%d (1) {
72    ["descriptor"]=>
73    resource(%d) of type (oci8 descriptor)
74  }
75}
76string(41) "string was%0%0%0%0%0%0%0%0%0%0k-tack-tick-tack.some"
77Done
78