Skip to content

Commit a8d9d1a

Browse files
committed
Add test for new execute() signature
1 parent 9a77fec commit a8d9d1a

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
SQLite3::prepare and execute with parameters as array
3+
--EXTENSIONS--
4+
sqlite3
5+
--FILE--
6+
<?php
7+
8+
require_once(__DIR__ . '/new_db.inc');
9+
define('TIMENOW', time());
10+
11+
echo "Creating Table\n";
12+
var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)'));
13+
14+
echo "INSERT into table\n";
15+
var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')"));
16+
var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')"));
17+
18+
echo "SELECTING results\n";
19+
$stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC");
20+
$foo = 'a';
21+
echo "BINDING Value\n";
22+
$results = $stmt->execute([$foo]);
23+
while ($result = $results->fetchArray(SQLITE3_NUM))
24+
{
25+
var_dump($result);
26+
}
27+
$results->finalize();
28+
29+
echo "Closing database\n";
30+
var_dump($db->close());
31+
echo "Done\n";
32+
?>
33+
--EXPECTF--
34+
Creating Table
35+
bool(true)
36+
INSERT into table
37+
bool(true)
38+
bool(true)
39+
SELECTING results
40+
BINDING Value
41+
array(2) {
42+
[0]=>
43+
int(%d)
44+
[1]=>
45+
string(1) "a"
46+
}
47+
Closing database
48+
bool(true)
49+
Done

0 commit comments

Comments
 (0)