mysqli_warning_count.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. mysqli_warning_count()
  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_warning_count()))
  15. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  16. if (!is_null($tmp = @mysqli_warning_count($link)))
  17. printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  18. require('table.inc');
  19. if (NULL !== ($tmp = @mysqli_warning_count($link, "too_many")))
  20. printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  21. if (!$res = mysqli_query($link, "SELECT id, label FROM test"))
  22. printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  23. if (0 !== ($tmp = mysqli_warning_count($link)))
  24. printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
  25. if (!mysqli_query($link, "DROP TABLE IF EXISTS this_table_does_not_exist"))
  26. printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  27. if (1 !== ($tmp = mysqli_warning_count($link)))
  28. printf("[007] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
  29. mysqli_close($link);
  30. if (NULL !== ($tmp = mysqli_warning_count($link)))
  31. printf("[010] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  32. print "done!";
  33. ?>
  34. --CLEAN--
  35. <?php
  36. require_once("clean_table.inc");
  37. ?>
  38. --EXPECTF--
  39. Warning: mysqli_warning_count(): Couldn't fetch mysqli in %s on line %d
  40. done!