bind_sqltchr_1.phpt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. --TEST--
  2. Bind with SQLT_CHR
  3. --SKIPIF--
  4. <?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
  5. --FILE--
  6. <?php
  7. require(dirname(__FILE__).'/connect.inc');
  8. // Initialization
  9. $stmtarray = array(
  10. "drop table bind_sqltchr_tab",
  11. "create table bind_sqltchr_tab (
  12. id number,
  13. varchar2_t10 varchar2(10),
  14. number_t number,
  15. number_t92 number(9,2))"
  16. );
  17. oci8_test_sql_execute($c, $stmtarray);
  18. function check_col($c, $colname, $id)
  19. {
  20. $s = oci_parse($c, "select $colname from bind_sqltchr_tab where id = :id");
  21. oci_bind_by_name($s, ":id", $id);
  22. oci_execute($s);
  23. oci_fetch_all($s, $r);
  24. var_dump($r);
  25. }
  26. // Run Test
  27. echo "\nTEST241 bind SQLT_CHR\n";
  28. $c2 = "Hood241";
  29. $s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, varchar2_t10) VALUES (241, :c2)");
  30. oci_bind_by_name($s, ":c2", $c2, -1, SQLT_CHR);
  31. oci_execute($s);
  32. check_col($c, 'varchar2_t10', 241);
  33. echo "\nTEST242 insert numbers SQLT_CHR\n";
  34. $s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (242, :n1)");
  35. $n1 = 42;
  36. oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
  37. oci_execute($s);
  38. check_col($c, 'number_t', 242);
  39. echo "\nTEST243 insert numbers, SQLT_CHR\n";
  40. $s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (243, :n1)");
  41. $n1 = 42.69;
  42. oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
  43. oci_execute($s);
  44. check_col($c, 'number_t', 243);
  45. echo "\nTEST244 insert numbers with SQLT_CHR\n";
  46. $s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (244, :n1)");
  47. $n1 = 0;
  48. oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
  49. oci_execute($s);
  50. check_col($c, 'number_t', 244);
  51. echo "\nTEST245 insert numbers with SQLT_CHR\n";
  52. $s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (245, :n1)");
  53. $n1 = -23;
  54. oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
  55. oci_execute($s);
  56. check_col($c, 'number_t', 245);
  57. echo "\nTEST246 insert numbers\n";
  58. $s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (246, :n1)");
  59. $n1 = "-23";
  60. oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
  61. oci_execute($s);
  62. check_col($c, 'number_t', 246);
  63. echo "\nTEST247 insert numbers with SQLT_CHR\n";
  64. $s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t) VALUES (247, :n1)");
  65. $n1 = "23";
  66. oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
  67. oci_execute($s);
  68. check_col($c, 'number_t', 247);
  69. echo "\nTEST248 insert numbers with SQLT_CHR\n";
  70. $s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t92) VALUES (248, :n1)");
  71. $n1 = 123.56;
  72. oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
  73. oci_execute($s);
  74. check_col($c, 'number_t92', 248);
  75. echo "\nTEST249 insert numbers with SQLT_CHR\n";
  76. $s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t92) VALUES (249, :n1)");
  77. $n1 = "123.56";
  78. oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
  79. oci_execute($s);
  80. check_col($c, 'number_t92', 249);
  81. echo "\nTEST250 insert numbers with SQLT_CHR\n";
  82. $s = oci_parse($c, "INSERT INTO bind_sqltchr_tab (id, number_t92) VALUES (250, :n1)");
  83. $n1 = "";
  84. oci_bind_by_name($s, ":n1", $n1, -1, SQLT_CHR);
  85. oci_execute($s);
  86. check_col($c, 'number_t92', 250);
  87. // Clean up
  88. $stmtarray = array(
  89. "drop table bind_sqltchr_tab"
  90. );
  91. oci8_test_sql_execute($c, $stmtarray);
  92. ?>
  93. ===DONE===
  94. <?php exit(0); ?>
  95. --EXPECTF--
  96. TEST241 bind SQLT_CHR
  97. array(1) {
  98. ["VARCHAR2_T10"]=>
  99. array(1) {
  100. [0]=>
  101. string(7) "Hood241"
  102. }
  103. }
  104. TEST242 insert numbers SQLT_CHR
  105. array(1) {
  106. ["NUMBER_T"]=>
  107. array(1) {
  108. [0]=>
  109. string(2) "42"
  110. }
  111. }
  112. TEST243 insert numbers, SQLT_CHR
  113. array(1) {
  114. ["NUMBER_T"]=>
  115. array(1) {
  116. [0]=>
  117. string(5) "42.69"
  118. }
  119. }
  120. TEST244 insert numbers with SQLT_CHR
  121. array(1) {
  122. ["NUMBER_T"]=>
  123. array(1) {
  124. [0]=>
  125. string(1) "0"
  126. }
  127. }
  128. TEST245 insert numbers with SQLT_CHR
  129. array(1) {
  130. ["NUMBER_T"]=>
  131. array(1) {
  132. [0]=>
  133. string(3) "-23"
  134. }
  135. }
  136. TEST246 insert numbers
  137. array(1) {
  138. ["NUMBER_T"]=>
  139. array(1) {
  140. [0]=>
  141. string(3) "-23"
  142. }
  143. }
  144. TEST247 insert numbers with SQLT_CHR
  145. array(1) {
  146. ["NUMBER_T"]=>
  147. array(1) {
  148. [0]=>
  149. string(2) "23"
  150. }
  151. }
  152. TEST248 insert numbers with SQLT_CHR
  153. array(1) {
  154. ["NUMBER_T92"]=>
  155. array(1) {
  156. [0]=>
  157. string(6) "123.56"
  158. }
  159. }
  160. TEST249 insert numbers with SQLT_CHR
  161. array(1) {
  162. ["NUMBER_T92"]=>
  163. array(1) {
  164. [0]=>
  165. string(6) "123.56"
  166. }
  167. }
  168. TEST250 insert numbers with SQLT_CHR
  169. array(1) {
  170. ["NUMBER_T92"]=>
  171. array(1) {
  172. [0]=>
  173. NULL
  174. }
  175. }
  176. ===DONE===