1--TEST-- 2fetching the same lob several times 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'; 14 15$drop = "DROP table lob_test"; 16$statement = oci_parse($c, $drop); 17@oci_execute($statement); 18 19$create = "CREATE table lob_test(mykey NUMBER, lob_1 CLOB)"; 20$statement = oci_parse($c, $create); 21oci_execute($statement); 22 23$init = "INSERT INTO lob_test (mykey, lob_1) VALUES(1, EMPTY_CLOB()) RETURNING lob_1 INTO :mylob"; 24$statement = oci_parse($c, $init); 25$clob = oci_new_descriptor($c, OCI_D_LOB); 26oci_bind_by_name($statement, ":mylob", $clob, -1, OCI_B_CLOB); 27oci_execute($statement, OCI_DEFAULT); 28oci_lob_save($clob, "data"); 29unset($clob->descriptor); 30 31oci_commit($c); 32 33$init = "INSERT INTO lob_test (mykey, lob_1) VALUES(2, EMPTY_CLOB()) RETURNING lob_1 INTO :mylob"; 34$statement = oci_parse($c, $init); 35$clob = oci_new_descriptor($c, OCI_D_LOB); 36oci_bind_by_name($statement, ":mylob", $clob, -1, OCI_B_CLOB); 37oci_execute($statement, OCI_DEFAULT); 38$clob->save("long data"); 39$clob->save("long data", 0); 40 41try { 42 $clob->save("long data", -1); 43} catch (ValueError $e) { 44 echo $e->getMessage(), "\n"; 45} 46 47oci_commit($c); 48 49$query = 'SELECT * FROM lob_test ORDER BY mykey ASC'; 50$statement = oci_parse ($c, $query); 51oci_execute($statement, OCI_DEFAULT); 52 53while ($row = oci_fetch_array($statement, OCI_ASSOC)) { 54 $result = $row['LOB_1']->load(); 55 var_dump($result); 56} 57 58$query = 'SELECT * FROM lob_test ORDER BY mykey DESC'; 59$statement = oci_parse ($c, $query); 60oci_execute($statement, OCI_DEFAULT); 61 62while ($row = oci_fetch_array($statement, OCI_ASSOC)) { 63 $result = $row['LOB_1']->load(); 64 var_dump($result); 65} 66 67$drop = "DROP table lob_test"; 68$statement = oci_parse($c, $drop); 69@oci_execute($statement); 70 71echo "Done\n"; 72 73?> 74--EXPECT-- 75 76OCILob::save(): Argument #2 ($offset) must be greater than or equal to 0 77string(4) "data" 78string(9) "long data" 79string(9) "long data" 80string(4) "data" 81Done 82