This repository has been archived by the owner on Sep 10, 2021. It is now read-only.
/
sqlite001.phpt
82 lines (65 loc) · 1.65 KB
/
sqlite001.phpt
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
70
71
72
73
74
75
76
77
78
79
80
81
82
--TEST--
sqlite3
--INI--
psi.directory={PWD}:{PWD}/../../psi.d
psi.blacklist.decls="sqlite3_str*,sqlite3_*serialize,sqlite3_stmt_scanstatus*,sqlite3_snapshot*,sqlite3_win32*,sqlite_normalize*"
--FILE--
===TEST===
<?php
var_dump(sqlite3\version());
copy(__DIR__."/sqlite001.db", __DIR__."/sqlite001.tmp");
$rc = sqlite3\open(__DIR__."/sqlite001.tmp", $db);
if ($rc) {
printf("%s\n", sqlite3\errstr($rc));
}
function callback($context, int $argc, array $argv, array $cols) {
$context->row = $context->row ?? 0;
for ($i = 0; $i < $argc; ++$i) {
printf("%d: %s = %s\n", $context->row, $cols[$i], $argv[$i] ?? "<NULL>");
}
printf("\n");
++$context->row;
}
$rc = sqlite3\exec($db, "SELECT * FROM test", "callback", new stdClass, $error);
if ($rc) {
printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
}
$rc = sqlite3\exec($db, "INSERT INTO test VALUES (3,'three')", "callback", new stdClass, $error);
if ($rc) {
printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
}
$rc = sqlite3\exec($db, "SELECT * FROM test", "callback", new stdClass, $error);
if ($rc) {
printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
}
$rc = sqlite3\exec($db, "SELECT *", "callback", new stdClass, $error);
if ($rc) {
printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
}
sqlite3\close($db);
$rc = sqlite3\exec($db, "SELECT *", "callback", new stdClass, $error);
if ($rc) {
printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
}
?>
===DONE===
--EXPECTF--
===TEST===
string(%d) "3.%d.%s"
0: id = 1
0: data = one
1: id = 2
1: data = two
0: id = 1
0: data = one
1: id = 2
1: data = two
2: id = 3
2: data = three
SQL logic error%s
%s: ''
===DONE===
--CLEAN--
<?php
@unlink(__DIR__."/sqlite001.tmp");
?>