1--TEST--
2SQLite3::query Unfinalized statement tests
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$results = $db->query("SELECT * FROM test ORDER BY id ASC");
20while ($result = $results->fetchArray(SQLITE3_NUM))
21{
22    var_dump($result);
23    /* Only read one row and break */
24    break;
25}
26
27echo "Closing database\n";
28var_dump($db->close());
29echo "Check db was closed\n";
30try {
31    var_dump($results->numColumns());
32} catch (\Error $e) {
33    echo $e->getMessage() . \PHP_EOL;
34}
35echo "Done\n";
36?>
37--EXPECTF--
38Creating Table
39bool(true)
40INSERT into table
41bool(true)
42bool(true)
43SELECTING results
44array(2) {
45  [0]=>
46  int(%d)
47  [1]=>
48  string(1) "a"
49}
50Closing database
51bool(true)
52Check db was closed
53The SQLite3Result object has not been correctly initialised or is already closed
54Done
55