Annotation of embedaddon/php/ext/oci8/tests/lob_031.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test LOB->read(), LOB->seek() and LOB->tell() with nul bytes in data
3: --SKIPIF--
4: <?php
5: $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
6: require(dirname(__FILE__).'/skipif.inc');
7: ?>
8: --FILE--
9: <?php
10:
11: require dirname(__FILE__).'/connect.inc';
12: require dirname(__FILE__).'/create_table.inc';
13:
14: $ora_sql = "INSERT INTO
15: ".$schema.$table_name." (blob)
16: VALUES (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);
23: oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
24: oci_execute($statement, OCI_DEFAULT);
25:
26: $blob->write("test");
27: $blob->tell();
28: $blob->seek(10, OCI_SEEK_CUR);
29: $blob->write("string");
30: $blob->flush();
31:
32: $select_sql = "SELECT blob FROM ".$schema.$table_name;
33: $s = oci_parse($c, $select_sql);
34: oci_execute($s);
35: $row = oci_fetch_array($s);
36:
37: $row[0]->read(3);
38: echo " 1. ".$row[0]->tell(). "\n";
39:
40: $row[0]->read(3);
41: echo " 2. ".$row[0]->tell(). "\n";
42:
43: $row[0]->read(3);
44: echo " 3. ".$row[0]->tell(). "\n";
45:
46: $row[0]->read(6);
47: echo " 4. ".$row[0]->tell(). "\n";
48:
49: $row[0]->read(4);
50: echo " 5. ".$row[0]->tell(). "\n";
51:
52: // Read past end
53: $row[0]->read(5);
54: echo " 6. ".$row[0]->tell(). "\n";
55:
56: $row[0]->read(1);
57: echo " 8. ".$row[0]->tell(). "\n";
58:
59: // Now seek
60: $row[0]->seek(1);
61: echo " 9. ".$row[0]->tell(). "\n";
62:
63: $row[0]->seek(8);
64: echo "10. ".$row[0]->tell(). "\n";
65:
66: $row[0]->seek(20);
67: echo "11. ".$row[0]->tell(). "\n";
68:
69: // Seek past end
70: $row[0]->seek(25);
71: echo "12. ".$row[0]->tell(). "\n";
72:
73: // Seek past end
74: $row[0]->seek(2, OCI_SEEK_SET);
75: echo "13. ".$row[0]->tell(). "\n";
76:
77: // Move on 2 more
78: $row[0]->seek(2, OCI_SEEK_CUR);
79: echo "14. ".$row[0]->tell(). "\n";
80:
81: // Move 3 past the end
82: $row[0]->seek(3, OCI_SEEK_END);
83: echo "15. ".$row[0]->tell(). "\n";
84:
85: // Move 4 before the end
86: $row[0]->seek(-4, OCI_SEEK_END);
87: echo "16. ".$row[0]->tell(). "\n";
88:
89: require dirname(__FILE__).'/drop_table.inc';
90:
91: echo "Done\n";
92:
93: ?>
94: --EXPECTF--
95: 1. 3
96: 2. 6
97: 3. 9
98: 4. 15
99: 5. 19
100: 6. 20
101: 8. 20
102: 9. 1
103: 10. 8
104: 11. 20
105: 12. 25
106: 13. 2
107: 14. 4
108: 15. 23
109: 16. 16
110: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>