xref: /PHP-5.3/ext/sqlite/tests/sqlite_oo_021.phpt (revision 610c7fbe)
1--TEST--
2sqlite-oo: single query
3--SKIPIF--
4<?php # vim:ft=php
5if (!extension_loaded("sqlite")) print "skip"; ?>
6--FILE--
7<?php
8include "blankdb_oo.inc";
9
10$db->query("CREATE TABLE test_db ( id INTEGER PRIMARY KEY, data VARCHAR(100) )");
11for ($i = 0; $i < 10; $i++) {
12	$db->query("INSERT INTO test_db (data) VALUES('{$i}data')");
13}
14$db->query("INSERT INTO test_db (data) VALUES(NULL)");
15
16var_dump($db->singleQuery("SELECT id FROM test_db WHERE id=5"));
17var_dump($db->singleQuery("SELECT * FROM test_db WHERE id=4"));
18var_dump($db->singleQuery("SELECT data FROM test_db WHERE id=6"));
19var_dump($db->singleQuery("SELECT * FROM test_db WHERE id < 5"));
20var_dump($db->singleQuery("SELECT * FROM test db WHERE id < 4"));
21var_dump($db->singleQuery("SELECT * FROM test_db WHERE id=999999"));
22var_dump($db->singleQuery("SELECT id FROM test_db WHERE id=5", FALSE));
23
24echo "DONE!\n";
25?>
26--EXPECTF--
27string(1) "5"
28string(1) "4"
29string(5) "5data"
30array(4) {
31  [0]=>
32  string(1) "1"
33  [1]=>
34  string(1) "2"
35  [2]=>
36  string(1) "3"
37  [3]=>
38  string(1) "4"
39}
40
41Warning: SQLiteDatabase::singleQuery(): no such table: test in %s on line %d
42bool(false)
43NULL
44array(1) {
45  [0]=>
46  string(1) "5"
47}
48DONE!
49