mysqli_sqlstate.phpt 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --TEST--
  2. mysqli_sqlstate()
  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. $tmp = NULL;
  13. $link = NULL;
  14. if (!is_null($tmp = @mysqli_sqlstate()))
  15. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  16. if (!is_null($tmp = @mysqli_sqlstate($link)))
  17. printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  18. require('table.inc');
  19. var_dump(@mysqli_sqlstate($link, "foo"));
  20. var_dump(mysqli_sqlstate($link));
  21. mysqli_query($link, "SELECT unknown_column FROM test");
  22. var_dump(mysqli_sqlstate($link));
  23. mysqli_free_result(mysqli_query($link, "SELECT id FROM test"));
  24. var_dump(mysqli_sqlstate($link));
  25. mysqli_close($link);
  26. var_dump(mysqli_sqlstate($link));
  27. print "done!";
  28. ?>
  29. --CLEAN--
  30. <?php
  31. require_once("clean_table.inc");
  32. ?>
  33. --EXPECTF--
  34. NULL
  35. %s(5) "00000"
  36. %s(5) "42S22"
  37. %s(5) "00000"
  38. Warning: mysqli_sqlstate(): Couldn't fetch mysqli in %s on line %d
  39. NULL
  40. done!