Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<SQLite3::enableExceptionsSQLite3::escapeString>
^SQLite3Last updated: Mon, 26 Oct 2026

SQLite3::enableExtendedResultCodes

(PHP 7 >= 7.4.0, PHP 8)

SQLite3::enableExtendedResultCodes — Enables or disables the use of extended result codes

Description

public function SQLite3::enableExtendedResultCodes(bool $enable = true): bool

Enables or disables the use of extended result codes, which are then reported by SQLite3::lastErrorCode(). SQLite3::lastExtendedErrorCode() is not affected by this setting, and always returns the extended result code.

Parameters

enable

Whether to enable (true) or disable (false) the use of extended result codes.

Return Values

Returns true on success or false on failure.

Examples

Example #1 SQLite3::enableExtendedResultCodes() example

<?php
$db = new SQLite3(':memory:');
$db->enableExceptions(true);
$db->exec('CREATE TABLE t (a INTEGER UNIQUE)');
$db->exec('INSERT INTO t VALUES (1)');

try {
    $db->exec('INSERT INTO t VALUES (1)');
} catch (Exception $e) {
}

// The primary result code (SQLITE_CONSTRAINT), then the extended result
// code (SQLITE_CONSTRAINT_UNIQUE).
var_dump($db->lastErrorCode(), $db->lastExtendedErrorCode());

// Once enabled, SQLite3::lastErrorCode() reports the extended result code
// as well.
$db->enableExtendedResultCodes();
var_dump($db->lastErrorCode());
?>

The above example will output:

int(19)
int(2067)
int(2067)

See Also


<SQLite3::enableExceptionsSQLite3::escapeString>
^SQLite3Last updated: Mon, 26 Oct 2026