mysql_tablename.phpt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. mysql_tablename()
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. require_once('skipifconnectfailure.inc');
  7. ?>
  8. --FILE--
  9. <?php
  10. include "connect.inc";
  11. $tmp = NULL;
  12. $link = NULL;
  13. if (!is_null($tmp = @mysql_tablename()))
  14. printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  15. if (null !== ($tmp = @mysql_tablename($link)))
  16. printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  17. require('table.inc');
  18. if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 2", $link)) {
  19. printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
  20. }
  21. if (NULL !== ($tmp = mysql_tablename($res)))
  22. printf("[004] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  23. if (false !== ($tmp = mysql_tablename($res, -1)))
  24. printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  25. var_dump(mysql_tablename($res, 0));
  26. if (false !== ($tmp = mysql_tablename($res, 2)))
  27. printf("[00%d] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  28. mysql_free_result($res);
  29. var_dump(mysql_tablename($res, 0));
  30. mysql_close($link);
  31. print "done!";
  32. ?>
  33. --EXPECTF--
  34. 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
  35. Warning: mysql_tablename() expects at least 2 parameters, 1 given in %s on line %d
  36. Warning: mysql_tablename(): Unable to jump to row -1 on MySQL result index %d in %s on line %d
  37. %unicode|string%(1) "1"
  38. Warning: mysql_tablename(): Unable to jump to row 2 on MySQL result index %d in %s on line %d
  39. Warning: mysql_tablename(): %d is not a valid MySQL result resource in %s on line %d
  40. bool(false)
  41. done!