mysqli_stmt_prepare.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. mysqli_stmt_prepare()
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once("connect.inc");
  12. // Note: No SQL tests here! We can expand one of the *fetch()
  13. // tests to a generic SQL test, if we ever need that.
  14. // We would duplicate the SQL test cases if we have it here and in one of the
  15. // fetch tests, because the fetch tests would have to call prepare/execute etc.
  16. // anyway.
  17. require('table.inc');
  18. if (!$stmt = mysqli_stmt_init($link))
  19. printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  20. if (false !== ($tmp = mysqli_stmt_prepare($stmt, '')))
  21. printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  22. if (true !== ($tmp = mysqli_stmt_prepare($stmt, 'SELECT id FROM test')))
  23. printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
  24. mysqli_stmt_close($stmt);
  25. try {
  26. mysqli_stmt_prepare($stmt, "SELECT id FROM test");
  27. } catch (Error $exception) {
  28. echo $exception->getMessage() . "\n";
  29. }
  30. mysqli_close($link);
  31. print "done!";
  32. ?>
  33. --CLEAN--
  34. <?php
  35. require_once("clean_table.inc");
  36. ?>
  37. --EXPECT--
  38. mysqli_stmt object is already closed
  39. done!