1--TEST--
2Test sqlite_last_error() function : basic functionality
3--SKIPIF--
4<?php if (!extension_loaded("sqlite")) print "skip sqlite extension not loaded"; ?>
5--FILE--
6<?php
7/* Prototype  : int sqlite_last_error(resource db)
8 * Description: Returns the error code of the last error for a database.
9 * Source code: ext/sqlite/sqlite.c
10 * Alias to functions:
11 */
12
13echo "*** Testing sqlite_last_error() : basic functionality ***\n";
14
15// set up variables
16$query = 'CREATE TAB LE foobar (id INTEGER PRIMARY KEY, name CHAR(255));';
17$query_ok = 'CREATE TABLE foobar (id INTEGER, name CHAR(255));';
18
19// procedural
20$db = sqlite_open(':memory:');
21var_dump( sqlite_last_error($db) === SQLITE_OK );
22sqlite_exec($db, $query);
23var_dump( sqlite_last_error($db) === SQLITE_ERROR );
24sqlite_exec($db, $query_ok);
25var_dump( sqlite_last_error($db) === SQLITE_OK );
26sqlite_close($db);
27
28// oo-style
29$db = new SQLiteDatabase(':memory:');
30$db->queryExec($query);
31var_dump( $db->lastError() === SQLITE_ERROR );
32$db->queryExec($query_ok);
33var_dump( $db->lastError() === SQLITE_OK );
34
35?>
36===DONE===
37--EXPECTF--
38*** Testing sqlite_last_error() : basic functionality ***
39bool(true)
40
41Warning: sqlite_exec(): near "TAB": syntax error in %s on line %d
42bool(true)
43bool(true)
44
45Warning: SQLiteDatabase::queryExec(): near "TAB": syntax error in %s on line %d
46bool(true)
47bool(true)
48===DONE===
49