summaryrefslogtreecommitdiff
path: root/ext/sqlite/tests
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2003-07-13 09:38:33 +0000
committerWez Furlong <wez@php.net>2003-07-13 09:38:33 +0000
commit78e236da261c5894f2fcf5c4fe227681081aac72 (patch)
treefb0d2bce7f7f75698b5fc454ea8053e33d1be2e6 /ext/sqlite/tests
parent80ee75f11ebef0a9c067bc6132c59ed32ad04129 (diff)
downloadphp-git-78e236da261c5894f2fcf5c4fe227681081aac72.tar.gz
Add sqlite_has_prev, and sqlite_prev.
Patch by Jan Lehnardt <jan@php.net>
Diffstat (limited to 'ext/sqlite/tests')
-rw-r--r--ext/sqlite/tests/sqlite_023.phpt103
1 files changed, 103 insertions, 0 deletions
diff --git a/ext/sqlite/tests/sqlite_023.phpt b/ext/sqlite/tests/sqlite_023.phpt
new file mode 100644
index 0000000000..ca1bee6b18
--- /dev/null
+++ b/ext/sqlite/tests/sqlite_023.phpt
@@ -0,0 +1,103 @@
+--TEST--
+sqlite: sqlite_[has_]prev
+--INI--
+sqlite.assoc_case=0
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded("sqlite")) print "skip"; ?>
+--FILE--
+<?php
+include "blankdb.inc";
+
+$data = array(
+ "one",
+ "two",
+ "three"
+ );
+
+sqlite_query("CREATE TABLE strings(a)", $db);
+
+foreach ($data as $str) {
+ sqlite_query("INSERT INTO strings VALUES('$str')", $db);
+}
+
+$r = sqlite_query("SELECT a FROM strings", $db, SQLITE_NUM);
+
+echo "====TRAVERSE====\n";
+for(sqlite_rewind($r); sqlite_has_more($r); sqlite_next($r)) {
+ var_dump(sqlite_current($r));
+
+}
+echo "====REVERSE====\n";
+do {
+ sqlite_prev($r);
+ var_dump(sqlite_current($r));
+} while(sqlite_has_prev($r));
+
+echo "====UNBUFFERED====\n";
+
+$r = sqlite_unbuffered_query("SELECT a FROM strings", $db, SQLITE_NUM);
+
+echo "====TRAVERSE====\n";
+for(sqlite_rewind($r); sqlite_has_more($r); sqlite_next($r)) {
+ var_dump(sqlite_current($r));
+
+}
+echo "====REVERSE====\n";
+do {
+ sqlite_prev($r);
+ var_dump(sqlite_current($r));
+} while(sqlite_has_prev($r));
+
+echo "====DONE!====\n";
+?>
+--EXPECTF--
+====TRAVERSE====
+array(1) {
+ [0]=>
+ string(3) "one"
+}
+array(1) {
+ [0]=>
+ string(3) "two"
+}
+array(1) {
+ [0]=>
+ string(5) "three"
+}
+====REVERSE====
+array(1) {
+ [0]=>
+ string(5) "three"
+}
+array(1) {
+ [0]=>
+ string(3) "two"
+}
+array(1) {
+ [0]=>
+ string(3) "one"
+}
+====UNBUFFERED====
+====TRAVERSE====
+
+Warning: sqlite_rewind(): Cannot rewind an unbuffered result set in %ssqlite_023.php on line %d
+array(1) {
+ [0]=>
+ string(3) "one"
+}
+array(1) {
+ [0]=>
+ string(3) "two"
+}
+array(1) {
+ [0]=>
+ string(5) "three"
+}
+====REVERSE====
+
+Warning: sqlite_prev(): you cannot use sqlite_prev on unbuffered querys in %ssqlite_023.php on line %d
+bool(false)
+
+Warning: sqlite_has_prev(): you cannot use sqlite_has_prev on unbuffered querys in %ssqlite_023.php on line %d
+====DONE!====