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.

155 lines
2.6 KiB

21 years ago
  1. --TEST--
  2. sqlite: sqlite_[has_]prev
  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. $r = sqlite_query("SELECT a FROM strings", $db, SQLITE_NUM);
  21. echo "====TRAVERSE====\n";
  22. for(sqlite_rewind($r); sqlite_valid($r); sqlite_next($r)) {
  23. var_dump(sqlite_current($r));
  24. }
  25. echo "====REVERSE====\n";
  26. do {
  27. sqlite_prev($r);
  28. var_dump(sqlite_current($r));
  29. } while(sqlite_has_prev($r));
  30. echo "====UNBUFFERED====\n";
  31. $r = sqlite_unbuffered_query("SELECT a FROM strings", $db, SQLITE_NUM);
  32. echo "====TRAVERSE====\n";
  33. for(sqlite_rewind($r); sqlite_valid($r); sqlite_next($r)) {
  34. var_dump(sqlite_current($r));
  35. }
  36. echo "====REVERSE====\n";
  37. do {
  38. sqlite_prev($r);
  39. var_dump(sqlite_current($r));
  40. } while(sqlite_has_prev($r));
  41. sqlite_close($db);
  42. echo "====DONE!====\n";
  43. ?>
  44. --EXPECTF--
  45. ====TRAVERSE====
  46. array(1) {
  47. [0]=>
  48. string(3) "one"
  49. }
  50. array(1) {
  51. [0]=>
  52. string(3) "two"
  53. }
  54. array(1) {
  55. [0]=>
  56. string(5) "three"
  57. }
  58. ====REVERSE====
  59. array(1) {
  60. [0]=>
  61. string(5) "three"
  62. }
  63. array(1) {
  64. [0]=>
  65. string(3) "two"
  66. }
  67. array(1) {
  68. [0]=>
  69. string(3) "one"
  70. }
  71. ====UNBUFFERED====
  72. ====TRAVERSE====
  73. Warning: sqlite_rewind(): Cannot rewind an unbuffered result set in %ssqlite_023.php on line %d
  74. array(1) {
  75. [0]=>
  76. string(3) "one"
  77. }
  78. array(1) {
  79. [0]=>
  80. string(3) "two"
  81. }
  82. array(1) {
  83. [0]=>
  84. string(5) "three"
  85. }
  86. ====REVERSE====
  87. Warning: sqlite_prev(): you cannot use sqlite_prev on unbuffered querys in %ssqlite_023.php on line %d
  88. bool(false)
  89. Warning: sqlite_has_prev(): you cannot use sqlite_has_prev on unbuffered querys in %ssqlite_023.php on line %d
  90. ====DONE!====
  91. --UEXPECTF--
  92. ====TRAVERSE====
  93. array(1) {
  94. [0]=>
  95. unicode(3) "one"
  96. }
  97. array(1) {
  98. [0]=>
  99. unicode(3) "two"
  100. }
  101. array(1) {
  102. [0]=>
  103. unicode(5) "three"
  104. }
  105. ====REVERSE====
  106. array(1) {
  107. [0]=>
  108. unicode(5) "three"
  109. }
  110. array(1) {
  111. [0]=>
  112. unicode(3) "two"
  113. }
  114. array(1) {
  115. [0]=>
  116. unicode(3) "one"
  117. }
  118. ====UNBUFFERED====
  119. ====TRAVERSE====
  120. Warning: sqlite_rewind(): Cannot rewind an unbuffered result set in %ssqlite_023.php on line %d
  121. array(1) {
  122. [0]=>
  123. unicode(3) "one"
  124. }
  125. array(1) {
  126. [0]=>
  127. unicode(3) "two"
  128. }
  129. array(1) {
  130. [0]=>
  131. unicode(5) "three"
  132. }
  133. ====REVERSE====
  134. Warning: sqlite_prev(): you cannot use sqlite_prev on unbuffered querys in %ssqlite_023.php on line %d
  135. bool(false)
  136. Warning: sqlite_has_prev(): you cannot use sqlite_has_prev on unbuffered querys in %ssqlite_023.php on line %d
  137. ====DONE!====