mysqli_stmt_prepare.phpt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. mysqli_stmt_prepare()
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifemb.inc');
  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. $tmp = NULL;
  18. $link = NULL;
  19. if (!is_null($tmp = @mysqli_stmt_prepare()))
  20. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  21. if (!is_null($tmp = @mysqli_stmt_prepare($link)))
  22. printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  23. require('table.inc');
  24. if (!$stmt = mysqli_stmt_init($link))
  25. printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  26. if (NULL !== ($tmp = @mysqli_stmt_prepare($stmt)))
  27. printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  28. if (false !== ($tmp = mysqli_stmt_prepare($stmt, '')))
  29. printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  30. if (true !== ($tmp = mysqli_stmt_prepare($stmt, 'SELECT id FROM test')))
  31. printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
  32. mysqli_stmt_close($stmt);
  33. if (NULL !== ($tmp = mysqli_stmt_prepare($stmt, "SELECT id FROM test")))
  34. printf("[007] Expecting NULL, got %s/%s\n");
  35. mysqli_close($link);
  36. print "done!";
  37. ?>
  38. --CLEAN--
  39. <?php
  40. require_once("clean_table.inc");
  41. ?>
  42. --EXPECTF--
  43. Warning: mysqli_stmt_prepare(): Couldn't fetch mysqli_stmt in %s on line %d
  44. done!