1--TEST-- 2sqlite: sqlite_seek 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$res = sqlite_query("SELECT a FROM strings", $db, SQLITE_NUM); 25for ($idx = -1; $idx < 4; $idx++) { 26 echo "====SEEK:$idx====\n"; 27 sqlite_seek($res, $idx); 28 var_dump(sqlite_current($res)); 29} 30echo "====AGAIN====\n"; 31for ($idx = -1; $idx < 4; $idx++) { 32 echo "====SEEK:$idx====\n"; 33 sqlite_seek($res, $idx); 34 var_dump(sqlite_current($res)); 35} 36 37sqlite_close($db); 38 39echo "====DONE!====\n"; 40?> 41--EXPECTF-- 42====SEEK:-1==== 43 44Warning: sqlite_seek(): row -1 out of range in %ssqlite_022.php on line %d 45array(1) { 46 [0]=> 47 string(3) "one" 48} 49====SEEK:0==== 50array(1) { 51 [0]=> 52 string(3) "one" 53} 54====SEEK:1==== 55array(1) { 56 [0]=> 57 string(3) "two" 58} 59====SEEK:2==== 60array(1) { 61 [0]=> 62 string(5) "three" 63} 64====SEEK:3==== 65 66Warning: sqlite_seek(): row 3 out of range in %ssqlite_022.php on line %d 67array(1) { 68 [0]=> 69 string(5) "three" 70} 71====AGAIN==== 72====SEEK:-1==== 73 74Warning: sqlite_seek(): row -1 out of range in %ssqlite_022.php on line %d 75array(1) { 76 [0]=> 77 string(5) "three" 78} 79====SEEK:0==== 80array(1) { 81 [0]=> 82 string(3) "one" 83} 84====SEEK:1==== 85array(1) { 86 [0]=> 87 string(3) "two" 88} 89====SEEK:2==== 90array(1) { 91 [0]=> 92 string(5) "three" 93} 94====SEEK:3==== 95 96Warning: sqlite_seek(): row 3 out of range in %ssqlite_022.php on line %d 97array(1) { 98 [0]=> 99 string(5) "three" 100} 101====DONE!==== 102