xref: /PHP-5.4/ext/oci8/tests/lob_035.phpt (revision c7a8bd6a)
1--TEST--
2oci_lob_copy() - 2
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
55$dummy = oci_new_descriptor($c, OCI_D_LOB);
56
57var_dump(oci_lob_copy($dummy, $row1[0]));
58var_dump(oci_lob_copy($row2[0], $dummy));
59
60var_dump(oci_lob_copy($row2[0], $row1[0], 0));
61var_dump(oci_lob_copy($row2[0], $row1[0], -1));
62var_dump(oci_lob_copy($row2[0], $row1[0], 100000));
63
64var_dump(oci_lob_size());
65var_dump(oci_lob_size($row2[0]));
66unset($dummy->descriptor);
67var_dump(oci_lob_size($dummy));
68
69oci_rollback($c);
70oci_rollback($c);
71oci_commit($c);
72oci_commit($c);
73
74$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE";
75$s = oci_parse($c, $select_sql);
76oci_execute($s, OCI_DEFAULT);
77
78var_dump($row2 = oci_fetch_array($s, OCI_RETURN_LOBS));
79
80require dirname(__FILE__).'/drop_table.inc';
81
82echo "Done\n";
83
84?>
85--EXPECTF--
86int(32)
87
88Warning: oci_lob_copy(): OCI_INVALID_HANDLE in %s on line %d
89bool(false)
90
91Warning: oci_lob_copy(): OCI_INVALID_HANDLE in %s on line %d
92bool(false)
93bool(false)
94
95Warning: oci_lob_copy(): Length parameter must be greater than 0 in %s on line %d
96bool(false)
97bool(true)
98
99Warning: oci_lob_size() expects exactly 1 parameter, 0 given in %s on line %d
100NULL
101int(0)
102
103Warning: oci_lob_size(): Unable to find descriptor property in %s on line %d
104bool(false)
105array(2) {
106  [0]=>
107  string(0) ""
108  ["BLOB"]=>
109  string(0) ""
110}
111Done
112