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