mysqli_stmt_close.phpt 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. --TEST--
  2. mysqli_stmt_close()
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once("connect.inc");
  12. require('table.inc');
  13. if (!$stmt = mysqli_stmt_init($link))
  14. printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  15. // Yes, amazing, eh? AFAIK a work around of a constructor bug...
  16. try {
  17. mysqli_stmt_close($stmt);
  18. } catch (Error $exception) {
  19. echo $exception->getMessage() . "\n";
  20. }
  21. if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test"))
  22. printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  23. if (true !== ($tmp = mysqli_stmt_close($stmt)))
  24. printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
  25. try {
  26. mysqli_stmt_close($stmt);
  27. } catch (Error $exception) {
  28. echo $exception->getMessage() . "\n";
  29. }
  30. if (!$stmt = mysqli_stmt_init($link))
  31. printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  32. if (!mysqli_stmt_prepare($stmt, "INSERT INTO test(id, label) VALUES (?, ?)"))
  33. printf("[009] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  34. $id = $label = null;
  35. if (!mysqli_stmt_bind_param($stmt, "is", $id, $label))
  36. printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  37. $id = 100; $label = 'z';
  38. if (!mysqli_stmt_execute($stmt))
  39. printf("[011] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  40. mysqli_kill($link, mysqli_thread_id($link));
  41. if (true !== ($tmp = mysqli_stmt_close($stmt)))
  42. printf("[012] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
  43. mysqli_close($link);
  44. require('table.inc');
  45. if (!$stmt = mysqli_stmt_init($link))
  46. printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  47. if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test"))
  48. printf("[014] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  49. $id = $label = null;
  50. if (!mysqli_stmt_bind_result($stmt, $id, $label))
  51. printf("[015] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  52. if (!mysqli_stmt_execute($stmt) || !mysqli_stmt_fetch($stmt))
  53. printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  54. mysqli_kill($link, mysqli_thread_id($link));
  55. if (true !== ($tmp = mysqli_stmt_close($stmt)))
  56. printf("[017] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
  57. print "done!";
  58. ?>
  59. --CLEAN--
  60. <?php
  61. require_once("clean_table.inc");
  62. ?>
  63. --EXPECT--
  64. mysqli_stmt object is not fully initialized
  65. mysqli_stmt object is already closed
  66. done!