PHP 8 compatibility
[m6w6/ext-psi] / tests / sqlite / sqlite001.phpt
1 --TEST--
2 sqlite3
3 --INI--
4 psi.directory={PWD}:{PWD}/../../psi.d
5 psi.blacklist.decls="sqlite3_str*,sqlite3_*serialize,sqlite3_stmt_scanstatus*,sqlite3_snapshot*,sqlite3_win32*,sqlite_normalize*"
6 --FILE--
7 ===TEST===
8 <?php
9
10 var_dump(sqlite3\version());
11
12 copy(__DIR__."/sqlite001.db", __DIR__."/sqlite001.tmp");
13
14 $rc = sqlite3\open(__DIR__."/sqlite001.tmp", $db);
15 if ($rc) {
16 printf("%s\n", sqlite3\errstr($rc));
17 }
18
19 function callback($context, int $argc, array $argv, array $cols) {
20 $context->row = $context->row ?? 0;
21
22 for ($i = 0; $i < $argc; ++$i) {
23 printf("%d: %s = %s\n", $context->row, $cols[$i], $argv[$i] ?? "<NULL>");
24 }
25 printf("\n");
26 ++$context->row;
27 }
28
29 $rc = sqlite3\exec($db, "SELECT * FROM test", "callback", new stdClass, $error);
30 if ($rc) {
31 printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
32 }
33
34 $rc = sqlite3\exec($db, "INSERT INTO test VALUES (3,'three')", "callback", new stdClass, $error);
35 if ($rc) {
36 printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
37 }
38
39 $rc = sqlite3\exec($db, "SELECT * FROM test", "callback", new stdClass, $error);
40 if ($rc) {
41 printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
42 }
43
44 $rc = sqlite3\exec($db, "SELECT *", "callback", new stdClass, $error);
45 if ($rc) {
46 printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
47 }
48
49 sqlite3\close($db);
50
51 $rc = sqlite3\exec($db, "SELECT *", "callback", new stdClass, $error);
52 if ($rc) {
53 printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
54 }
55
56 ?>
57 ===DONE===
58 --EXPECTF--
59 ===TEST===
60 string(%d) "3.%d.%s"
61 0: id = 1
62 0: data = one
63
64 1: id = 2
65 1: data = two
66
67 0: id = 1
68 0: data = one
69
70 1: id = 2
71 1: data = two
72
73 2: id = 3
74 2: data = three
75
76 SQL logic error%s
77 %s: ''
78 ===DONE===
79 --CLEAN--
80 <?php
81 @unlink(__DIR__."/sqlite001.tmp");
82 ?>