summaryrefslogtreecommitdiff
path: root/ext/sqlite/tests/sqlite_019.phpt
blob: f03dac85b2d06c4e15f1499de9542d26ba3dd05a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--TEST--
sqlite: single query
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded("sqlite")) print "skip"; ?>
--FILE--
<?php
include "blankdb.inc";
	
sqlite_query($db, "CREATE TABLE test_db ( id INTEGER PRIMARY KEY, data VARCHAR(100) )");
for ($i = 0; $i < 10; $i++) {
	sqlite_query($db, "INSERT INTO test_db (data) VALUES('{$i}data')");
}
sqlite_query($db, "INSERT INTO test_db (data) VALUES(NULL)");
	                                         
var_dump(sqlite_single_query($db, "SELECT id FROM test_db WHERE id=5"));
var_dump(sqlite_single_query($db, "SELECT * FROM test_db WHERE id=4"));
var_dump(sqlite_single_query($db, "SELECT data FROM test_db WHERE id=6"));
var_dump(sqlite_single_query($db, "SELECT * FROM test_db WHERE id < 5"));
var_dump(sqlite_single_query($db, "SELECT * FROM test db WHERE id < 4"));
var_dump(sqlite_single_query($db, "SELECT * FROM test_db WHERE id=999999"));
var_dump(sqlite_single_query($db, "SELECT id FROM test_db WHERE id=5", FALSE));

sqlite_close($db);
?>
--EXPECTF--
string(1) "5"
string(1) "4"
string(5) "5data"
array(4) {
  [0]=>
  string(1) "1"
  [1]=>
  string(1) "2"
  [2]=>
  string(1) "3"
  [3]=>
  string(1) "4"
}

Warning: sqlite_single_query(): no such table: test in %s on line %d
bool(false)
NULL
array(1) {
  [0]=>
  string(1) "5"
}
--UEXPECTF--
unicode(1) "5"
unicode(1) "4"
unicode(5) "5data"
array(4) {
  [0]=>
  unicode(1) "1"
  [1]=>
  unicode(1) "2"
  [2]=>
  unicode(1) "3"
  [3]=>
  unicode(1) "4"
}

Warning: sqlite_single_query(): no such table: test in %s on line %d
bool(false)
NULL
array(1) {
  [0]=>
  unicode(1) "5"
}