xref: /PHP-7.2/ext/oci8/tests/lob_011.phpt (revision 37652336)
1--TEST--
2oci_lob_copy()
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." (id, blob)
16                      VALUES (1, 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->write("some string here. string, I said"));
27oci_commit($c);
28
29$ora_sql = "INSERT INTO
30                       ".$schema.$table_name." (id, blob)
31                      VALUES (2, empty_blob())
32                      RETURNING
33                               blob
34                      INTO :v_blob ";
35
36$statement = oci_parse($c,$ora_sql);
37$blob = oci_new_descriptor($c,OCI_D_LOB);
38oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
39oci_execute($statement, OCI_DEFAULT);
40
41oci_commit($c);
42
43$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 1";
44$s = oci_parse($c, $select_sql);
45oci_execute($s);
46
47$row1 = oci_fetch_array($s);
48
49$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE";
50$s = oci_parse($c, $select_sql);
51oci_execute($s, OCI_DEFAULT);
52
53$row2 = oci_fetch_array($s);
54
55var_dump(oci_lob_copy($row2[0], $row1[0]));
56var_dump($row1[0]->read(100));
57
58oci_commit($c);
59
60$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE";
61$s = oci_parse($c, $select_sql);
62oci_execute($s, OCI_DEFAULT);
63
64var_dump($row2 = oci_fetch_array($s, OCI_RETURN_LOBS));
65
66require dirname(__FILE__).'/drop_table.inc';
67
68echo "Done\n";
69
70?>
71--EXPECT--
72int(32)
73bool(true)
74string(32) "some string here. string, I said"
75array(2) {
76  [0]=>
77  string(32) "some string here. string, I said"
78  ["BLOB"]=>
79  string(32) "some string here. string, I said"
80}
81Done
82