mysqli_data_seek.phpt 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. --TEST--
  2. mysqli_data_seek()
  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 (NULL !== ($tmp = @mysqli_data_seek()))
  15. printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
  16. if (NULL !== ($tmp = @mysqli_data_seek($link)))
  17. printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
  18. if (NULL !== ($tmp = @mysqli_data_seek($link, $link)))
  19. printf("[003] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
  20. require('table.inc');
  21. if (!$res = mysqli_query($link, 'SELECT * FROM test ORDER BY id LIMIT 4', MYSQLI_STORE_RESULT))
  22. printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  23. if (true !== ($tmp = mysqli_data_seek($res, 3)))
  24. printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
  25. $row = mysqli_fetch_assoc($res);
  26. if (4 != $row['id'])
  27. printf("[006] Expecting record 4/d, got record %s/%s\n", $row['id'], $row['label']);
  28. if (true !== ($tmp = mysqli_data_seek($res, 0)))
  29. printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
  30. $row = mysqli_fetch_assoc($res);
  31. if (1 != $row['id'])
  32. printf("[008] Expecting record 1/a, got record %s/%s\n", $row['id'], $row['label']);
  33. if (false !== ($tmp = mysqli_data_seek($res, 4)))
  34. printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  35. if (false !== ($tmp = mysqli_data_seek($res, -1)))
  36. printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  37. mysqli_free_result($res);
  38. if (!$res = mysqli_query($link, 'SELECT * FROM test ORDER BY id', MYSQLI_USE_RESULT))
  39. printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
  40. if (false !== ($tmp = mysqli_data_seek($res, 3)))
  41. printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
  42. mysqli_free_result($res);
  43. if (NULL !== ($tmp = mysqli_data_seek($res, 1)))
  44. printf("[013] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
  45. mysqli_close($link);
  46. print "done!";
  47. ?>
  48. --CLEAN--
  49. <?php
  50. require_once("clean_table.inc");
  51. ?>
  52. --EXPECTF--
  53. Warning: mysqli_data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d
  54. Warning: mysqli_data_seek(): Couldn't fetch mysqli_result in %s on line %d
  55. done!