xref: /PHP-8.3/ext/oci8/tests/lob_031.phpt (revision a53e5617)
1--TEST--
2Test LOB->read(), LOB->seek() and LOB->tell() with nul bytes in data
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." (blob)
19                      VALUES (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
29$blob->write("test");
30$blob->tell();
31$blob->seek(10, OCI_SEEK_CUR);
32$blob->write("string");
33$blob->flush();
34
35$select_sql = "SELECT blob FROM ".$schema.$table_name;
36$s = oci_parse($c, $select_sql);
37oci_execute($s);
38$row = oci_fetch_array($s);
39
40$row[0]->read(3);
41echo " 1. ".$row[0]->tell(). "\n";
42
43$row[0]->read(3);
44echo " 2. ".$row[0]->tell(). "\n";
45
46$row[0]->read(3);
47echo " 3. ".$row[0]->tell(). "\n";
48
49$row[0]->read(6);
50echo " 4. ".$row[0]->tell(). "\n";
51
52$row[0]->read(4);
53echo " 5. ".$row[0]->tell(). "\n";
54
55// Read past end
56$row[0]->read(5);
57echo " 6. ".$row[0]->tell(). "\n";
58
59$row[0]->read(1);
60echo " 8. ".$row[0]->tell(). "\n";
61
62// Now seek
63$row[0]->seek(1);
64echo " 9. ".$row[0]->tell(). "\n";
65
66$row[0]->seek(8);
67echo "10. ".$row[0]->tell(). "\n";
68
69$row[0]->seek(20);
70echo "11. ".$row[0]->tell(). "\n";
71
72// Seek past end
73$row[0]->seek(25);
74echo "12. ".$row[0]->tell(). "\n";
75
76// Seek past end
77$row[0]->seek(2, OCI_SEEK_SET);
78echo "13. ".$row[0]->tell(). "\n";
79
80// Move on 2 more
81$row[0]->seek(2, OCI_SEEK_CUR);
82echo "14. ".$row[0]->tell(). "\n";
83
84// Move 3 past the end
85$row[0]->seek(3, OCI_SEEK_END);
86echo "15. ".$row[0]->tell(). "\n";
87
88// Move 4 before the end
89$row[0]->seek(-4, OCI_SEEK_END);
90echo "16. ".$row[0]->tell(). "\n";
91
92require __DIR__.'/drop_table.inc';
93
94echo "Done\n";
95
96?>
97--EXPECT--
98 1. 3
99 2. 6
100 3. 9
101 4. 15
102 5. 19
103 6. 20
104 8. 20
105 9. 1
10610. 8
10711. 20
10812. 25
10913. 2
11014. 4
11115. 23
11216. 16
113Done
114