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

Açıklama

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.

Bağımsız Değişkenler

enable

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

Dönen Değerler

Başarı durumunda true, başarısızlık durumunda false döner.

Örnekler

Örnek 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());
?>

Yukarıdaki örneğin çıktısı:

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

Ayrıca Bakınız

add a note

User Contributed Notes

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