1--TEST--
2SQLite3 extended error code Function
3--EXTENSIONS--
4sqlite3
5--FILE--
6<?php
7
8require_once(__DIR__ . '/new_db.inc');
9
10$db->query("CREATE TABLE dog ( id INTEGER PRIMARY KEY, name TEXT, annoying INTEGER )");
11
12echo "Inserting first time which should succeed" . PHP_EOL;
13$result = $db->query("INSERT INTO dog VALUES (1, 'Annoying Dog', 1)");
14echo "First Error Code: " . $db->lastErrorCode() . PHP_EOL;
15
16echo "Inserting second time which should fail" . PHP_EOL;
17$result = $db->query("INSERT INTO dog VALUES (1, 'Annoying Dog', 1)");
18echo "Second Error Code: " . $db->lastErrorCode() . PHP_EOL;
19echo "Second Extended Error Code: " . $db->lastExtendedErrorCode() . PHP_EOL;
20
21echo "Closing database\n";
22var_dump($db->close());
23echo "Done" . PHP_EOL;
24?>
25--EXPECTF--
26Inserting first time which should succeed
27First Error Code: 0
28Inserting second time which should fail
29
30Warning: SQLite3::query(): Unable to execute statement: UNIQUE constraint failed: dog.id in %s on line %d
31Second Error Code: 19
32Second Extended Error Code: 1555
33Closing database
34bool(true)
35Done
36
37