1--TEST-- 2Bind with NUMBER column variants 3--SKIPIF-- 4<?php 5if (!extension_loaded('oci8')) die("skip no oci8 extension"); 6?> 7--INI-- 8precision = 14 9--FILE-- 10<?php 11 12require(__DIR__.'/connect.inc'); 13 14// Initialization 15 16$stmtarray = array( 17 "drop table bind_number_tab", 18 "create table bind_number_tab ( 19 id number, 20 number_t6 number(6), 21 float_t float, 22 binary_float_t binary_float, 23 binary_double_t binary_double, 24 decimal_t decimal, 25 integer_t integer)" 26); 27 28oci8_test_sql_execute($c, $stmtarray); 29 30function check_col($c, $colname, $id) 31{ 32 $s = oci_parse($c, "select $colname from bind_number_tab where id = :id"); 33 oci_bind_by_name($s, ":id", $id); 34 oci_execute($s); 35 oci_fetch_all($s, $r); 36 var_dump($r); 37} 38 39// Run Test 40 41echo "Test 1 - invalid number\n"; 42 43$s = oci_parse($c, "INSERT INTO bind_number_tab (id, number_t6) VALUES (1, :n1)"); 44$n1 = "Hello"; 45oci_bind_by_name($s, ":n1", $n1); 46oci_execute($s); 47 48check_col($c, "number_t6", 1); 49 50echo "\nTEST66 insert a float\n"; 51 52$s = oci_parse($c, "INSERT INTO bind_number_tab (id, float_t) VALUES (66, :f1)"); 53$f1 = 123.456; 54oci_bind_by_name($s, ":f1", $f1); 55oci_execute($s); 56 57check_col($c, 'float_t', 66); 58 59echo "\nTEST67 insert a binary float\n"; 60 61$s = oci_parse($c, "INSERT INTO bind_number_tab (id, binary_float_t) VALUES (67, :f1)"); 62$f1 = 567.456; 63oci_bind_by_name($s, ":f1", $f1); 64oci_execute($s); 65 66check_col($c, 'binary_float_t', 67); 67 68echo "\nTEST69 insert a binary double\n"; 69 70$s = oci_parse($c, "INSERT INTO bind_number_tab (id, binary_double_t) VALUES (69, :f1)"); 71$f1 = 567.456; 72oci_bind_by_name($s, ":f1", $f1); 73oci_execute($s); 74 75check_col($c, 'binary_double_t', 69); 76 77echo "\nTEST71 insert a decimal\n"; 78 79$s = oci_parse($c, "INSERT INTO bind_number_tab (id, decimal_t) VALUES (71, :f1)"); 80$f1 = 123.789; 81oci_bind_by_name($s, ":f1", $f1); 82oci_execute($s); 83 84check_col($c, 'decimal_t', 71); 85 86echo "\nTEST72 insert a decimal\n"; 87 88$s = oci_parse($c, "INSERT INTO bind_number_tab (id, decimal_t) VALUES (72, :f1)"); 89$f1 = 123.789; 90oci_bind_by_name($s, ":f1", $f1, -1, SQLT_NUM); 91oci_execute($s); 92 93check_col($c, 'decimal_t', 72); 94 95echo "\nTEST73 insert a double\n"; 96 97$s = oci_parse($c, "INSERT INTO bind_number_tab (id, binary_double_t) VALUES (73, :f1)"); 98$f1 = 483.589; 99oci_bind_by_name($s, ":f1", $f1); 100oci_execute($s); 101 102check_col($c, 'binary_double_t', 73); 103 104echo "\nTEST75 insert a INTEGER\n"; 105 106$s = oci_parse($c, "INSERT INTO bind_number_tab (id, integer_t) VALUES (75, :f1)"); 107$f1 = 589; 108oci_bind_by_name($s, ":f1", $f1); 109oci_execute($s); 110 111check_col($c, 'integer_t', 75); 112 113echo "\nTEST76 insert a INTEGER\n"; 114 115$s = oci_parse($c, "INSERT INTO bind_number_tab (id, integer_t) VALUES (76, :f1)"); 116$f1 = 42; 117oci_bind_by_name($s, ":f1", $f1, -1, SQLT_INT); 118oci_execute($s); 119 120check_col($c, 'integer_t', 76); 121 122 123// Clean up 124 125$stmtarray = array( 126 "drop table bind_number_tab" 127); 128 129oci8_test_sql_execute($c, $stmtarray); 130 131?> 132--EXPECTF-- 133Test 1 - invalid number 134 135Warning: oci_execute(): ORA-01722: %s in %sbind_number.php on line %d 136array(1) { 137 ["NUMBER_T6"]=> 138 array(0) { 139 } 140} 141 142TEST66 insert a float 143array(1) { 144 ["FLOAT_T"]=> 145 array(1) { 146 [0]=> 147 string(7) "123.456" 148 } 149} 150 151TEST67 insert a binary float 152array(1) { 153 ["BINARY_FLOAT_T"]=> 154 array(1) { 155 [0]=> 156 string(%r15|8%r) "%r(5.67455994E\+002|567.4560)%r" 157 } 158} 159 160TEST69 insert a binary double 161array(1) { 162 ["BINARY_DOUBLE_T"]=> 163 array(1) { 164 [0]=> 165 string(%r23|16%r) "%r(5.6745600000000002E\+002|567.456000000000)%r" 166 } 167} 168 169TEST71 insert a decimal 170array(1) { 171 ["DECIMAL_T"]=> 172 array(1) { 173 [0]=> 174 string(3) "124" 175 } 176} 177 178TEST72 insert a decimal 179array(1) { 180 ["DECIMAL_T"]=> 181 array(1) { 182 [0]=> 183 string(1) "0" 184 } 185} 186 187TEST73 insert a double 188array(1) { 189 ["BINARY_DOUBLE_T"]=> 190 array(1) { 191 [0]=> 192 string(%r12|16%r) "%r(4.83589E\+002|483.589000000000)%r" 193 } 194} 195 196TEST75 insert a INTEGER 197array(1) { 198 ["INTEGER_T"]=> 199 array(1) { 200 [0]=> 201 string(3) "589" 202 } 203} 204 205TEST76 insert a INTEGER 206array(1) { 207 ["INTEGER_T"]=> 208 array(1) { 209 [0]=> 210 string(2) "42" 211 } 212} 213