0 follower

Final Class Yiisoft\Db\Sqlite\Transaction

InheritanceYiisoft\Db\Sqlite\Transaction » Yiisoft\Db\Driver\Pdo\AbstractPdoTransaction

Implements the SQLite Server specific transaction.

Protected Methods

Hide inherited methods

Method Description Defined By
setTransactionIsolationLevel() Sets the isolation level of the current transaction. Yiisoft\Db\Sqlite\Transaction

Method Details

Hide inherited methods

setTransactionIsolationLevel() protected method

Sets the isolation level of the current transaction.

See also:

  • \Yiisoft\Db\Transaction\TransactionInterface::READ_UNCOMMITTED
  • \Yiisoft\Db\Transaction\TransactionInterface::SERIALIZABLE
protected void setTransactionIsolationLevel ( string $level )
$level string

The transaction isolation level to use for this transaction.

throws \Yiisoft\Db\Exception\Exception
throws \Yiisoft\Db\Exception\InvalidConfigException
throws \Yiisoft\Db\Exception\NotSupportedException
throws Throwable

When unsupported isolation levels are used. SQLite only supports SERIALIZABLE and READ UNCOMMITTED.

                protected function setTransactionIsolationLevel(string $level): void
{
    match ($level) {
        self::SERIALIZABLE => $this->db->createCommand('PRAGMA read_uncommitted = False;')->execute(),
        self::READ_UNCOMMITTED => $this->db->createCommand('PRAGMA read_uncommitted = True;')->execute(),
        default => throw new NotSupportedException(
            self::class . ' only supports transaction isolation levels READ UNCOMMITTED and SERIALIZABLE.',
        ),
    };
}