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

Опис

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.

Параметри

enable

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

Значення, що повертаються

Повертає true у разі успіху або false в разі помилки.

Приклади

Приклад #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());
?>

Поданий вище приклад виведе:

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

Прогляньте також

add a note

User Contributed Notes

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