mysql_data_seek.phpt 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. --TEST--
  2. mysql_data_seek()
  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 (NULL !== ($tmp = @mysql_data_seek()))
  14. printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  15. if (NULL !== ($tmp = @mysql_data_seek($link)))
  16. printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  17. if (NULL !== ($tmp = @mysql_data_seek($link, $link)))
  18. printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  19. require('table.inc');
  20. if (!$res = mysql_query('SELECT * FROM test ORDER BY id LIMIT 4', $link))
  21. printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link));
  22. if (true !== ($tmp = mysql_data_seek($res, 3)))
  23. printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
  24. $row = mysql_fetch_assoc($res);
  25. if (4 != $row['id'])
  26. printf("[006] Expecting record 4/d, got record %s/%s\n", $row['id'], $row['label']);
  27. if (true !== ($tmp = mysql_data_seek($res, 0)))
  28. printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
  29. $row = mysql_fetch_assoc($res);
  30. if (1 != $row['id'])
  31. printf("[008] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']);
  32. if (false !== ($tmp = mysql_data_seek($res, 4)))
  33. printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  34. if (false !== ($tmp = mysql_data_seek($res, -1)))
  35. printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  36. mysql_free_result($res);
  37. if (!$res = mysql_unbuffered_query('SELECT * FROM test ORDER BY id', $link))
  38. printf("[011] [%d] %s\n", mysql_errno($link), mysql_error($link));
  39. if (false !== ($tmp = mysql_data_seek($res, 3)))
  40. printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  41. mysql_free_result($res);
  42. if (false !== ($tmp = mysql_data_seek($res, 1)))
  43. printf("[013] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  44. mysql_close($link);
  45. print "done!\n";
  46. ?>
  47. --CLEAN--
  48. <?php
  49. require_once("clean_table.inc");
  50. ?>
  51. --EXPECTF--
  52. 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
  53. Warning: mysql_data_seek(): Offset 4 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d
  54. Warning: mysql_data_seek(): Offset -1 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d
  55. Warning: mysql_data_seek(): Offset 3 is invalid for MySQL result index %d (or the query data is unbuffered) in %s on line %d
  56. Warning: mysql_data_seek(): %d is not a valid MySQL result resource in %s on line %d
  57. done!