mysqli_errno_oo.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. $mysqli->errno
  3. --EXTENSIONS--
  4. mysqli
  5. --SKIPIF--
  6. <?php
  7. require_once('skipifconnectfailure.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once("connect.inc");
  12. $tmp = NULL;
  13. $link = NULL;
  14. $mysqli = new mysqli();
  15. if (0 !== ($tmp = @$mysqli->errno))
  16. printf("[001] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
  17. if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
  18. printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
  19. $host, $user, $db, $port, $socket);
  20. var_dump($mysqli->errno);
  21. if (!$mysqli->query('DROP TABLE IF EXISTS test')) {
  22. printf("[003] Failed to drop old test table: [%d] %s\n", $mysqli->errno, $mysqli->error);
  23. }
  24. $mysqli->query('SELECT * FROM test');
  25. var_dump($mysqli->errno);
  26. @$mysqli->query('No SQL');
  27. if (($tmp = $mysqli->errno) === 0)
  28. printf("[004] Expecting int/any non zero got %s/%s\n", gettype($tmp), $tmp);
  29. $mysqli->close();
  30. try {
  31. $mysqli->errno;
  32. } catch (Error $exception) {
  33. echo $exception->getMessage() . "\n";
  34. }
  35. print "done!";
  36. ?>
  37. --EXPECTF--
  38. int(0)
  39. int(%d)
  40. mysqli object is already closed
  41. done!