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