PHP 8.5.10 Released!

SQLite3::enableExtendedResultCodes

(PHP 7 >= 7.4.0, PHP 8)

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

Beschreibung

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.

Parameter-Liste

enable

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

Rückgabewerte

Gibt bei Erfolg true zurück. Bei einem Fehler wird false zurückgegeben.

Beispiele

Beispiel #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());
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

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

Siehe auch

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top