You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
1.6 KiB

  1. --TEST--
  2. sqlite: sqlite_seek
  3. --INI--
  4. sqlite.assoc_case=0
  5. --SKIPIF--
  6. <?php # vim:ft=php
  7. if (!extension_loaded("sqlite")) print "skip"; ?>
  8. --FILE--
  9. <?php
  10. include "blankdb.inc";
  11. $data = array(
  12. "one",
  13. "two",
  14. "three"
  15. );
  16. sqlite_query("CREATE TABLE strings(a)", $db);
  17. foreach ($data as $str) {
  18. sqlite_query("INSERT INTO strings VALUES('$str')", $db);
  19. }
  20. $res = sqlite_query("SELECT a FROM strings", $db, SQLITE_NUM);
  21. for ($idx = -1; $idx < 4; $idx++) {
  22. echo "====SEEK:$idx====\n";
  23. sqlite_seek($res, $idx);
  24. var_dump(sqlite_current($res));
  25. }
  26. echo "====AGAIN====\n";
  27. for ($idx = -1; $idx < 4; $idx++) {
  28. echo "====SEEK:$idx====\n";
  29. sqlite_seek($res, $idx);
  30. var_dump(sqlite_current($res));
  31. }
  32. sqlite_close($db);
  33. echo "====DONE!====\n";
  34. ?>
  35. --EXPECTF--
  36. ====SEEK:-1====
  37. Warning: sqlite_seek(): row -1 out of range in %ssqlite_022.php on line %d
  38. array(1) {
  39. [0]=>
  40. string(3) "one"
  41. }
  42. ====SEEK:0====
  43. array(1) {
  44. [0]=>
  45. string(3) "one"
  46. }
  47. ====SEEK:1====
  48. array(1) {
  49. [0]=>
  50. string(3) "two"
  51. }
  52. ====SEEK:2====
  53. array(1) {
  54. [0]=>
  55. string(5) "three"
  56. }
  57. ====SEEK:3====
  58. Warning: sqlite_seek(): row 3 out of range in %ssqlite_022.php on line %d
  59. array(1) {
  60. [0]=>
  61. string(5) "three"
  62. }
  63. ====AGAIN====
  64. ====SEEK:-1====
  65. Warning: sqlite_seek(): row -1 out of range in %ssqlite_022.php on line %d
  66. array(1) {
  67. [0]=>
  68. string(5) "three"
  69. }
  70. ====SEEK:0====
  71. array(1) {
  72. [0]=>
  73. string(3) "one"
  74. }
  75. ====SEEK:1====
  76. array(1) {
  77. [0]=>
  78. string(3) "two"
  79. }
  80. ====SEEK:2====
  81. array(1) {
  82. [0]=>
  83. string(5) "three"
  84. }
  85. ====SEEK:3====
  86. Warning: sqlite_seek(): row 3 out of range in %ssqlite_022.php on line %d
  87. array(1) {
  88. [0]=>
  89. string(5) "three"
  90. }
  91. ====DONE!====