xref: /PHP-7.2/ext/oci8/tests/lob_037.phpt (revision a2c0f872)
1--TEST--
2Fetching two different lobs and using them after fetch
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/* insert the first LOB */
15$ora_sql = "INSERT INTO
16                       ".$schema.$table_name." (blob)
17                      VALUES (empty_blob())
18                      RETURNING
19                               blob
20                      INTO :v_blob ";
21
22$s = oci_parse($c,$ora_sql);
23$blob = oci_new_descriptor($c,OCI_DTYPE_LOB);
24
25oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
26oci_execute($s, OCI_DEFAULT);
27
28var_dump($blob->write("first lob data"));
29oci_commit($c);
30
31/* insert the second LOB */
32$ora_sql = "INSERT INTO
33                       ".$schema.$table_name." (blob)
34                      VALUES (empty_blob())
35                      RETURNING
36                               blob
37                      INTO :v_blob ";
38
39$s = oci_parse($c,$ora_sql);
40$blob = oci_new_descriptor($c,OCI_DTYPE_LOB);
41
42oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB);
43oci_execute($s, OCI_DEFAULT);
44
45var_dump($blob->write("second lob data"));
46oci_commit($c);
47
48/* select both */
49
50$ora_sql = "SELECT blob FROM ".$schema.$table_name;
51$s = oci_parse($c,$ora_sql);
52oci_execute($s, OCI_DEFAULT);
53
54$rows = array();
55$rows[0] = oci_fetch_assoc($s);
56$rows[1] = oci_fetch_assoc($s);
57
58var_dump($rows[0]['BLOB']->read(1000));
59var_dump($rows[1]['BLOB']->read(1000));
60
61require dirname(__FILE__).'/drop_table.inc';
62
63echo "Done\n";
64
65?>
66--EXPECT--
67int(14)
68int(15)
69string(14) "first lob data"
70string(15) "second lob data"
71Done
72