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