mysql_ping.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. mysql_ping()
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifconnectfailure.inc');
  7. ?>
  8. --FILE--
  9. <?php
  10. include_once "connect.inc";
  11. $tmp = NULL;
  12. $link = NULL;
  13. require('table.inc');
  14. if (!is_null($tmp = @mysql_ping($link, $link)))
  15. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  16. var_dump(mysql_ping($link));
  17. // provoke an error to check if mysql_ping resets it
  18. $res = mysql_query('SELECT * FROM unknown_table', $link);
  19. if (!($errno = mysql_errno($link)))
  20. printf("[002] Statement should have caused an error\n");
  21. var_dump(mysql_ping($link));
  22. if ($errno === mysql_errno($link))
  23. printf("[003] Error codes should have been reset\n");
  24. var_dump(mysql_ping());
  25. mysql_close($link);
  26. if (false !== ($tmp = mysql_ping($link)))
  27. printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  28. print "done!";
  29. ?>
  30. --CLEAN--
  31. <?php
  32. require_once("clean_table.inc");
  33. ?>
  34. --EXPECTF--
  35. Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in %s on line %d
  36. bool(true)
  37. bool(true)
  38. bool(true)
  39. Warning: mysql_ping(): %d is not a valid MySQL-Link resource in %s on line %d
  40. done!