bind_empty.phpt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. --TEST--
  2. binding empty values
  3. --SKIPIF--
  4. <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
  5. --FILE--
  6. <?php
  7. require dirname(__FILE__).'/connect.inc';
  8. $drop = "DROP table bind_empty_tab";
  9. $statement = oci_parse($c, $drop);
  10. @oci_execute($statement);
  11. $create = "CREATE table bind_empty_tab(name VARCHAR(10))";
  12. $statement = oci_parse($c, $create);
  13. oci_execute($statement);
  14. echo "Test 1\n";
  15. $name = null;
  16. $stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
  17. oci_bind_by_name($stmt, ":name", $name);
  18. var_dump(oci_execute($stmt));
  19. echo "Test 2\n";
  20. $name = "";
  21. $stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
  22. oci_bind_by_name($stmt, ":name", $name);
  23. var_dump(oci_execute($stmt));
  24. echo "Test 3\n";
  25. $stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('abc')");
  26. $res = oci_execute($stmt);
  27. $stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('def')");
  28. $res = oci_execute($stmt);
  29. $name = null;
  30. $stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'abc'");
  31. oci_bind_by_name($stmt, ":name", $name);
  32. var_dump(oci_execute($stmt));
  33. $stid = oci_parse($c, "select * from bind_empty_tab order by 1");
  34. oci_execute($stid);
  35. oci_fetch_all($stid, $res);
  36. var_dump($res);
  37. echo "Test 4\n";
  38. $name = "";
  39. $stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'def'");
  40. oci_bind_by_name($stmt, ":name", $name);
  41. var_dump(oci_execute($stmt));
  42. $stid = oci_parse($c, "select * from bind_empty_tab order by 1");
  43. oci_execute($stid);
  44. oci_fetch_all($stid, $res);
  45. var_dump($res);
  46. echo "Test 5\n";
  47. $av = $bv = 'old';
  48. $s = oci_parse($c, "begin :bv := null; end; ");
  49. oci_bind_by_name($s, ":bv", $bv);
  50. oci_execute($s);
  51. var_dump($av);
  52. var_dump($bv);
  53. echo "Test 6\n";
  54. $av = $bv = null;
  55. $s = oci_parse($c, "begin :bv := null; end; ");
  56. oci_bind_by_name($s, ":bv", $bv);
  57. oci_execute($s);
  58. var_dump($av);
  59. var_dump($bv);
  60. // Clean up
  61. $drop = "DROP table bind_empty_tab";
  62. $statement = oci_parse($c, $drop);
  63. @oci_execute($statement);
  64. ?>
  65. ===DONE===
  66. <?php exit(0); ?>
  67. --EXPECTF--
  68. Test 1
  69. bool(true)
  70. Test 2
  71. bool(true)
  72. Test 3
  73. bool(true)
  74. array(1) {
  75. ["NAME"]=>
  76. array(2) {
  77. [0]=>
  78. string(3) "def"
  79. [1]=>
  80. NULL
  81. }
  82. }
  83. Test 4
  84. bool(true)
  85. array(1) {
  86. ["NAME"]=>
  87. array(2) {
  88. [0]=>
  89. NULL
  90. [1]=>
  91. NULL
  92. }
  93. }
  94. Test 5
  95. string(3) "old"
  96. NULL
  97. Test 6
  98. NULL
  99. NULL
  100. ===DONE===