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