1--TEST-- 2Array fetch CLOB and BLOB 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 17echo "Test 1: CLOB\n"; 18 19$ora_sql = "INSERT INTO 20 ".$schema.$table_name." (clob) 21 VALUES (empty_clob()) 22 RETURNING 23 clob 24 INTO :v_clob "; 25 26$s = oci_parse($c,$ora_sql); 27$clob = oci_new_descriptor($c,OCI_DTYPE_LOB); 28 29 30oci_bind_by_name($s,":v_clob", $clob,-1,OCI_B_CLOB); 31 32oci_execute($s, OCI_DEFAULT); 33var_dump($clob->save("clob test 1")); 34 35oci_execute($s, OCI_DEFAULT); 36var_dump($clob->save("clob test 2")); 37 38oci_execute($s, OCI_DEFAULT); 39var_dump($clob->save("clob test 3")); 40 41 42$s = oci_parse($c,"select clob from ".$schema.$table_name); 43var_dump(oci_execute($s)); 44 45oci_fetch_all($s, $res); 46 47var_dump($res); 48 49 50echo "Test 1b\n"; 51 52$s = oci_parse($c, "select clob from ".$schema.$table_name); 53var_dump(oci_execute($s, OCI_DEFAULT)); 54while ($row = oci_fetch_array($s, OCI_ASSOC)) { 55 var_dump($row); 56 $result = $row['CLOB']->load(); 57 var_dump($result); 58} 59 60 61require __DIR__.'/drop_table.inc'; 62 63echo "Test 2: BLOB\n"; 64 65require __DIR__.'/create_table.inc'; 66 67$ora_sql = "INSERT INTO 68 ".$schema.$table_name." (blob) 69 VALUES (empty_blob()) 70 RETURNING 71 blob 72 INTO :v_blob "; 73 74$s = oci_parse($c,$ora_sql); 75$blob = oci_new_descriptor($c,OCI_DTYPE_LOB); 76 77 78oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB); 79 80oci_execute($s, OCI_DEFAULT); 81var_dump($blob->save("blob test 1")); 82 83oci_execute($s, OCI_DEFAULT); 84var_dump($blob->save("blob test 2")); 85 86oci_execute($s, OCI_DEFAULT); 87var_dump($blob->save("blob test 3")); 88 89$s = oci_parse($c, "select blob from ".$schema.$table_name); 90var_dump(oci_execute($s)); 91oci_fetch_all($s, $res); 92var_dump($res); 93 94echo "Test 2b\n"; 95 96$s = oci_parse($c, "select blob from ".$schema.$table_name); 97var_dump(oci_execute($s, OCI_DEFAULT)); 98while ($row = oci_fetch_array($s, OCI_ASSOC)) { 99 var_dump($row); 100 $result = $row['BLOB']->load(); 101 var_dump($result); 102} 103 104 105require __DIR__.'/drop_table.inc'; 106 107echo "Done\n"; 108 109?> 110--EXPECTF-- 111Test 1: CLOB 112bool(true) 113bool(true) 114bool(true) 115bool(true) 116array(1) { 117 ["CLOB"]=> 118 array(3) { 119 [0]=> 120 string(11) "clob test 1" 121 [1]=> 122 string(11) "clob test 2" 123 [2]=> 124 string(11) "clob test 3" 125 } 126} 127Test 1b 128bool(true) 129array(1) { 130 ["CLOB"]=> 131 object(OCILob)#2 (1) { 132 ["descriptor"]=> 133 resource(%d) of type (oci8 descriptor) 134 } 135} 136string(11) "clob test 1" 137array(1) { 138 ["CLOB"]=> 139 object(OCILob)#3 (1) { 140 ["descriptor"]=> 141 resource(%d) of type (oci8 descriptor) 142 } 143} 144string(11) "clob test 2" 145array(1) { 146 ["CLOB"]=> 147 object(OCILob)#2 (1) { 148 ["descriptor"]=> 149 resource(%d) of type (oci8 descriptor) 150 } 151} 152string(11) "clob test 3" 153Test 2: BLOB 154bool(true) 155bool(true) 156bool(true) 157bool(true) 158array(1) { 159 ["BLOB"]=> 160 array(3) { 161 [0]=> 162 string(11) "blob test 1" 163 [1]=> 164 string(11) "blob test 2" 165 [2]=> 166 string(11) "blob test 3" 167 } 168} 169Test 2b 170bool(true) 171array(1) { 172 ["BLOB"]=> 173 object(OCILob)#3 (1) { 174 ["descriptor"]=> 175 resource(%d) of type (oci8 descriptor) 176 } 177} 178string(11) "blob test 1" 179array(1) { 180 ["BLOB"]=> 181 object(OCILob)#4 (1) { 182 ["descriptor"]=> 183 resource(%d) of type (oci8 descriptor) 184 } 185} 186string(11) "blob test 2" 187array(1) { 188 ["BLOB"]=> 189 object(OCILob)#3 (1) { 190 ["descriptor"]=> 191 resource(%d) of type (oci8 descriptor) 192 } 193} 194string(11) "blob test 3" 195Done 196