1--TEST--
2SQLite3_stmt::readOnly check
3--EXTENSIONS--
4sqlite3
5--SKIPIF--
6<?php
7$version = SQLite3::version();
8if ($version['versionNumber'] < 3007004) {
9  die("skip");
10}
11?>
12--FILE--
13<?php
14
15require_once(__DIR__ . '/new_db.inc');
16define('TIMENOW', time());
17
18echo "Creating Table\n";
19var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)'));
20
21echo "INSERT into table\n";
22var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')"));
23var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')"));
24
25echo "Checking select statement\n";
26$stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC");
27var_dump($stmt->readOnly());
28
29echo "Checking update statement\n";
30$stmt = $db->prepare("UPDATE test SET id = 'c' WHERE id = ?");
31var_dump($stmt->readOnly());
32
33echo "Checking delete statement\n";
34$stmt = $db->prepare("DELETE FROM test");
35var_dump($stmt->readOnly());
36
37echo "Closing database\n";
38var_dump($db->close());
39echo "Done\n";
40?>
41--EXPECT--
42Creating Table
43bool(true)
44INSERT into table
45bool(true)
46bool(true)
47Checking select statement
48bool(true)
49Checking update statement
50bool(false)
51Checking delete statement
52bool(false)
53Closing database
54bool(true)
55Done
56