1--TEST-- 2sqlite: sqlite_[has_]prev 3--INI-- 4sqlite.assoc_case=0 5--SKIPIF-- 6<?php # vim:ft=php 7if (!extension_loaded("sqlite")) print "skip"; ?> 8--FILE-- 9<?php 10include "blankdb.inc"; 11 12$data = array( 13 "one", 14 "two", 15 "three" 16 ); 17 18sqlite_query("CREATE TABLE strings(a)", $db); 19 20foreach ($data as $str) { 21 sqlite_query("INSERT INTO strings VALUES('$str')", $db); 22} 23 24$r = sqlite_query("SELECT a FROM strings", $db, SQLITE_NUM); 25 26echo "====TRAVERSE====\n"; 27for(sqlite_rewind($r); sqlite_valid($r); sqlite_next($r)) { 28 var_dump(sqlite_current($r)); 29 30} 31echo "====REVERSE====\n"; 32do { 33 sqlite_prev($r); 34 var_dump(sqlite_current($r)); 35} while(sqlite_has_prev($r)); 36 37echo "====UNBUFFERED====\n"; 38 39$r = sqlite_unbuffered_query("SELECT a FROM strings", $db, SQLITE_NUM); 40 41echo "====TRAVERSE====\n"; 42for(sqlite_rewind($r); sqlite_valid($r); sqlite_next($r)) { 43 var_dump(sqlite_current($r)); 44 45} 46echo "====REVERSE====\n"; 47do { 48 sqlite_prev($r); 49 var_dump(sqlite_current($r)); 50} while(sqlite_has_prev($r)); 51 52sqlite_close($db); 53 54echo "====DONE!====\n"; 55?> 56--EXPECTF-- 57====TRAVERSE==== 58array(1) { 59 [0]=> 60 string(3) "one" 61} 62array(1) { 63 [0]=> 64 string(3) "two" 65} 66array(1) { 67 [0]=> 68 string(5) "three" 69} 70====REVERSE==== 71array(1) { 72 [0]=> 73 string(5) "three" 74} 75array(1) { 76 [0]=> 77 string(3) "two" 78} 79array(1) { 80 [0]=> 81 string(3) "one" 82} 83====UNBUFFERED==== 84====TRAVERSE==== 85 86Warning: sqlite_rewind(): Cannot rewind an unbuffered result set in %ssqlite_023.php on line %d 87array(1) { 88 [0]=> 89 string(3) "one" 90} 91array(1) { 92 [0]=> 93 string(3) "two" 94} 95array(1) { 96 [0]=> 97 string(5) "three" 98} 99====REVERSE==== 100 101Warning: sqlite_prev(): you cannot use sqlite_prev on unbuffered querys in %ssqlite_023.php on line %d 102bool(false) 103 104Warning: sqlite_has_prev(): you cannot use sqlite_has_prev on unbuffered querys in %ssqlite_023.php on line %d 105====DONE!==== 106