bind_sqltchr_1.phpt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. --TEST--
  2. Bind with SQLT_CHR
  3. --EXTENSIONS--
  4. oci8
  5. --FILE--
  6. <?php
  7. require(__DIR__.'/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. --EXPECT--
  94. TEST241 bind SQLT_CHR
  95. array(1) {
  96. ["VARCHAR2_T10"]=>
  97. array(1) {
  98. [0]=>
  99. string(7) "Hood241"
  100. }
  101. }
  102. TEST242 insert numbers SQLT_CHR
  103. array(1) {
  104. ["NUMBER_T"]=>
  105. array(1) {
  106. [0]=>
  107. string(2) "42"
  108. }
  109. }
  110. TEST243 insert numbers, SQLT_CHR
  111. array(1) {
  112. ["NUMBER_T"]=>
  113. array(1) {
  114. [0]=>
  115. string(5) "42.69"
  116. }
  117. }
  118. TEST244 insert numbers with SQLT_CHR
  119. array(1) {
  120. ["NUMBER_T"]=>
  121. array(1) {
  122. [0]=>
  123. string(1) "0"
  124. }
  125. }
  126. TEST245 insert numbers with SQLT_CHR
  127. array(1) {
  128. ["NUMBER_T"]=>
  129. array(1) {
  130. [0]=>
  131. string(3) "-23"
  132. }
  133. }
  134. TEST246 insert numbers
  135. array(1) {
  136. ["NUMBER_T"]=>
  137. array(1) {
  138. [0]=>
  139. string(3) "-23"
  140. }
  141. }
  142. TEST247 insert numbers with SQLT_CHR
  143. array(1) {
  144. ["NUMBER_T"]=>
  145. array(1) {
  146. [0]=>
  147. string(2) "23"
  148. }
  149. }
  150. TEST248 insert numbers with SQLT_CHR
  151. array(1) {
  152. ["NUMBER_T92"]=>
  153. array(1) {
  154. [0]=>
  155. string(6) "123.56"
  156. }
  157. }
  158. TEST249 insert numbers with SQLT_CHR
  159. array(1) {
  160. ["NUMBER_T92"]=>
  161. array(1) {
  162. [0]=>
  163. string(6) "123.56"
  164. }
  165. }
  166. TEST250 insert numbers with SQLT_CHR
  167. array(1) {
  168. ["NUMBER_T92"]=>
  169. array(1) {
  170. [0]=>
  171. NULL
  172. }
  173. }