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