xref: /PHP-5.3/ext/sqlite/tests/sqlite_oo_014.phpt (revision 610c7fbe)
1--TEST--
2sqlite-oo: fetch all
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_oo.inc";
11
12$data = array(
13	"one",
14	"two",
15	"three"
16	);
17
18$db->query("CREATE TABLE strings(a VARCHAR)");
19
20foreach ($data as $str) {
21	$db->query("INSERT INTO strings VALUES('$str')");
22}
23
24echo "unbuffered twice\n";
25$r = $db->unbufferedQuery("SELECT a from strings", SQLITE_NUM);
26var_dump($r->fetchAll());
27var_dump($r->fetchAll());
28
29echo "unbuffered with fetch_array\n";
30$r = $db->unbufferedQuery("SELECT a from strings", SQLITE_NUM);
31var_dump($r->fetch());
32var_dump($r->fetchAll());
33
34echo "buffered\n";
35$r = $db->query("SELECT a from strings", SQLITE_NUM);
36var_dump($r->fetchAll());
37var_dump($r->fetch());
38var_dump($r->fetchAll());
39
40echo "DONE!\n";
41?>
42--EXPECTF--
43unbuffered twice
44array(3) {
45  [0]=>
46  array(1) {
47    [0]=>
48    string(3) "one"
49  }
50  [1]=>
51  array(1) {
52    [0]=>
53    string(3) "two"
54  }
55  [2]=>
56  array(1) {
57    [0]=>
58    string(5) "three"
59  }
60}
61
62Warning: SQLiteUnbuffered::fetchAll(): One or more rowsets were already returned; returning NULL this time in %ssqlite_oo_014.php on line %d
63array(0) {
64}
65unbuffered with fetch_array
66array(1) {
67  [0]=>
68  string(3) "one"
69}
70array(2) {
71  [0]=>
72  array(1) {
73    [0]=>
74    string(3) "two"
75  }
76  [1]=>
77  array(1) {
78    [0]=>
79    string(5) "three"
80  }
81}
82buffered
83array(3) {
84  [0]=>
85  array(1) {
86    [0]=>
87    string(3) "one"
88  }
89  [1]=>
90  array(1) {
91    [0]=>
92    string(3) "two"
93  }
94  [2]=>
95  array(1) {
96    [0]=>
97    string(5) "three"
98  }
99}
100bool(false)
101array(3) {
102  [0]=>
103  array(1) {
104    [0]=>
105    string(3) "one"
106  }
107  [1]=>
108  array(1) {
109    [0]=>
110    string(3) "two"
111  }
112  [2]=>
113  array(1) {
114    [0]=>
115    string(5) "three"
116  }
117}
118DONE!
119