summaryrefslogtreecommitdiff
path: root/ext/sqlite/tests/sqlite_010.phpt
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2003-05-02 22:09:54 +0000
committerMarcus Boerger <helly@php.net>2003-05-02 22:09:54 +0000
commit7a17b231903ad7432e229c7b6fe025a22cbc62d2 (patch)
treeb9d99a405d8321c43637a56775cb57b1bbe460a4 /ext/sqlite/tests/sqlite_010.phpt
parent4701aaaa87c683867e99bfa72f4bcbac9c0a46ae (diff)
downloadphp-git-7a17b231903ad7432e229c7b6fe025a22cbc62d2.tar.gz
Add iterator interface and test
Diffstat (limited to 'ext/sqlite/tests/sqlite_010.phpt')
-rwxr-xr-xext/sqlite/tests/sqlite_010.phpt79
1 files changed, 61 insertions, 18 deletions
diff --git a/ext/sqlite/tests/sqlite_010.phpt b/ext/sqlite/tests/sqlite_010.phpt
index 493ac39463..3715747072 100755
--- a/ext/sqlite/tests/sqlite_010.phpt
+++ b/ext/sqlite/tests/sqlite_010.phpt
@@ -1,5 +1,5 @@
--TEST--
-sqlite: fetch all (unbuffered)
+sqlite: fetch all (iterator)
--INI--
sqlite.assoc_case=0
--SKIPIF--
@@ -9,27 +9,70 @@ if (!extension_loaded("sqlite")) print "skip"; ?>
<?php
include "blankdb.inc";
-sqlite_query("CREATE TABLE strings(foo VARCHAR, bar VARCHAR, baz VARCHAR)", $db);
+$data = array(
+ "one",
+ "two",
+ "three"
+ );
-echo "Buffered\n";
-$r = sqlite_query("SELECT * from strings", $db);
-for($i=0; $i<sqlite_num_fields($r); $i++) {
- var_dump(sqlite_field_name($r, $i));
+sqlite_query("CREATE TABLE strings(a VARCHAR)", $db);
+
+foreach ($data as $str) {
+ sqlite_query("INSERT INTO strings VALUES('$str')", $db);
+}
+
+$r = sqlite_unbuffered_query("SELECT a from strings", $db);
+while (sqlite_has_more($r)) {
+ var_dump(sqlite_current($r, SQLITE_NUM));
+ sqlite_next($r);
+}
+$r = sqlite_query("SELECT a from strings", $db);
+while (sqlite_has_more($r)) {
+ var_dump(sqlite_current($r, SQLITE_NUM));
+ sqlite_next($r);
}
-echo "Unbuffered\n";
-$r = sqlite_unbuffered_query("SELECT * from strings", $db);
-for($i=0; $i<sqlite_num_fields($r); $i++) {
- var_dump(sqlite_field_name($r, $i));
+sqlite_rewind($r);
+while (sqlite_has_more($r)) {
+ var_dump(sqlite_current($r, SQLITE_NUM));
+ sqlite_next($r);
}
echo "DONE!\n";
?>
--EXPECT--
-Buffered
-string(3) "foo"
-string(3) "bar"
-string(3) "baz"
-Unbuffered
-string(3) "foo"
-string(3) "bar"
-string(3) "baz"
+array(1) {
+ [0]=>
+ string(3) "one"
+}
+array(1) {
+ [0]=>
+ string(3) "two"
+}
+array(1) {
+ [0]=>
+ string(5) "three"
+}
+array(1) {
+ [0]=>
+ string(3) "one"
+}
+array(1) {
+ [0]=>
+ string(3) "two"
+}
+array(1) {
+ [0]=>
+ string(5) "three"
+}
+array(1) {
+ [0]=>
+ string(3) "one"
+}
+array(1) {
+ [0]=>
+ string(3) "two"
+}
+array(1) {
+ [0]=>
+ string(5) "three"
+}
DONE!