1--TEST-- 2oci_lob_copy() - 2 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'; 12require __DIR__.'/create_table.inc'; 13 14$ora_sql = "INSERT INTO 15 ".$schema.$table_name." (id, blob) 16 VALUES (1, 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); 23oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); 24oci_execute($statement, OCI_DEFAULT); 25 26echo "Writing blob\n"; 27var_dump($blob->write("some string here. string, I said")); 28oci_commit($c); 29 30$ora_sql = "INSERT INTO 31 ".$schema.$table_name." (id, blob) 32 VALUES (2, empty_blob()) 33 RETURNING 34 blob 35 INTO :v_blob "; 36 37$statement = oci_parse($c,$ora_sql); 38$blob = oci_new_descriptor($c,OCI_D_LOB); 39oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); 40oci_execute($statement, OCI_DEFAULT); 41 42oci_commit($c); 43 44$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 1"; 45$s = oci_parse($c, $select_sql); 46oci_execute($s); 47 48$row1 = oci_fetch_array($s); 49 50$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE"; 51$s = oci_parse($c, $select_sql); 52oci_execute($s, OCI_DEFAULT); 53 54$row2 = oci_fetch_array($s); 55 56$dummy = oci_new_descriptor($c, OCI_D_LOB); 57 58//-------------------------------------------------- 59 60echo "\noci_lob_copy invalid args\n"; 61 62var_dump(oci_lob_copy($dummy, $row1[0])); 63var_dump(oci_lob_copy($row2[0], $dummy)); 64var_dump(oci_lob_copy($row2[0], $row1[0], 0)); 65var_dump(oci_lob_copy($row2[0], $row1[0], 100000)); 66 67try { 68 var_dump(oci_lob_copy($row2[0], $row1[0], -1)); 69} catch (ValueError $e) { 70 echo $e->getMessage(), "\n"; 71} 72 73//-------------------------------------------------- 74 75echo "\noci_lob_size tests\n"; 76 77var_dump(oci_lob_size($row2[0])); 78unset($dummy->descriptor); 79var_dump(oci_lob_size($dummy)); 80 81oci_rollback($c); 82 83//-------------------------------------------------- 84 85echo "\nQuery test\n"; 86 87$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE"; 88$s = oci_parse($c, $select_sql); 89oci_execute($s, OCI_DEFAULT); 90 91var_dump($row2 = oci_fetch_array($s, OCI_RETURN_LOBS)); 92 93require __DIR__.'/drop_table.inc'; 94 95echo "Done\n"; 96 97?> 98--EXPECTF-- 99Writing blob 100int(32) 101 102oci_lob_copy invalid args 103 104Warning: oci_lob_copy(): OCI_INVALID_HANDLE in %s on line %d 105bool(false) 106 107Warning: oci_lob_copy(): OCI_INVALID_HANDLE in %s on line %d 108bool(false) 109bool(false) 110bool(true) 111oci_lob_copy(): Argument #3 ($length) must be greater than or equal to 0 112 113oci_lob_size tests 114int(0) 115 116Warning: oci_lob_size(): Unable to find descriptor property in %s on line %d 117bool(false) 118 119Query test 120array(2) { 121 [0]=> 122 string(0) "" 123 ["BLOB"]=> 124 string(0) "" 125} 126Done 127