xref: /PHP-8.3/ext/oci8/tests/lob_011.phpt (revision a53e5617)
1--TEST--
2oci_lob_copy()
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
9require __DIR__.'/skipif.inc';
10?>
11--FILE--
12<?php
13
14require __DIR__.'/connect.inc';
15require __DIR__.'/create_table.inc';
16
17$ora_sql = "INSERT INTO
18                       ".$schema.$table_name." (id, blob)
19                      VALUES (1, empty_blob())
20                      RETURNING
21                               blob
22                      INTO :v_blob ";
23
24$statement = oci_parse($c,$ora_sql);
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->write("some string here. string, I said"));
30oci_commit($c);
31
32$ora_sql = "INSERT INTO
33                       ".$schema.$table_name." (id, blob)
34                      VALUES (2, empty_blob())
35                      RETURNING
36                               blob
37                      INTO :v_blob ";
38
39$statement = oci_parse($c,$ora_sql);
40$blob = oci_new_descriptor($c,OCI_D_LOB);
41oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
42oci_execute($statement, OCI_DEFAULT);
43
44oci_commit($c);
45
46$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 1";
47$s = oci_parse($c, $select_sql);
48oci_execute($s);
49
50$row1 = oci_fetch_array($s);
51
52$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE";
53$s = oci_parse($c, $select_sql);
54oci_execute($s, OCI_DEFAULT);
55
56$row2 = oci_fetch_array($s);
57
58var_dump(oci_lob_copy($row2[0], $row1[0]));
59var_dump($row1[0]->read(100));
60
61oci_commit($c);
62
63$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE";
64$s = oci_parse($c, $select_sql);
65oci_execute($s, OCI_DEFAULT);
66
67var_dump($row2 = oci_fetch_array($s, OCI_RETURN_LOBS));
68
69require __DIR__.'/drop_table.inc';
70
71echo "Done\n";
72
73?>
74--EXPECT--
75int(32)
76bool(true)
77string(32) "some string here. string, I said"
78array(2) {
79  [0]=>
80  string(32) "some string here. string, I said"
81  ["BLOB"]=>
82  string(32) "some string here. string, I said"
83}
84Done
85