src/Db/Transaction.php
public function begin($isolationLevel = null)
    {
        if ($this->db === null) {
            $exception = new InvalidConfigException('Transaction::db must be set.');
            return Reaction\Promise\reject($exception);
        }

        $connection = $this->getConnection();

        if ($this->_level === 0) {
            $isolationLevel = isset($isolationLevel) ? $isolationLevel : self::READ_COMMITTED;
            Reaction::debug('Begin transaction' . ($isolationLevel ? ' with isolation level ' . $isolationLevel : ''));
            $this->_level = 1;
            $promise = $connection->beginTransaction($isolationLevel);
        } else {
            $schema = $this->db->getSchema();
            if ($schema->supportsSavepoint()) {
                Reaction::debug('Set savepoint ' . $this->_level);
                $promise = $connection->createSavepoint('LEVEL' . $this->_level);
            } else {
                Reaction::info('Transaction not started: nested transaction not supported');
            }
            $this->_level++;
        }

        if (!isset($promise)) {
            return Reaction\Promise\rejectLazy(null);
        }

        $callback = function() { return $this->getConnection(); };

        return $promise instanceof LazyPromiseInterface ? $promise->thenLazy($callback) : $promise->then($callback);
    }
public function begin($isolationLevel = null)
    {
        if ($this->db === null) {
            $exception = new InvalidConfigException('Transaction::db must be set.');
            return Reaction\Promise\reject($exception);
        }

        $connection = $this->getConnection();

        if ($this->_level === 0) {
            $isolationLevel = isset($isolationLevel) ? $isolationLevel : self::READ_COMMITTED;
            Reaction::debug('Begin transaction' . ($isolationLevel ? ' with isolation level ' . $isolationLevel : ''));
            $this->_level = 1;
            $promise = $connection->beginTransaction($isolationLevel);
        } else {
            $schema = $this->db->getSchema();
            if ($schema->supportsSavepoint()) {
                Reaction::debug('Set savepoint ' . $this->_level);
                $promise = $connection->createSavepoint('LEVEL' . $this->_level);
            } else {
                Reaction::info('Transaction not started: nested transaction not supported');
            }
            $this->_level++;
        }

        if (!isset($promise)) {
            return Reaction\Promise\rejectLazy(null);
        }

        $callback = function() { return $this->getConnection(); };

        return $promise instanceof LazyPromiseInterface ? $promise->thenLazy($callback) : $promise->then($callback);
    }
Begins a transaction.
@param string|null $isolationLevel The [isolation level][] to use for this transaction.
This can be one of [[READ_UNCOMMITTED]], [[READ_COMMITTED]], [[REPEATABLE_READ]] and [[SERIALIZABLE]] but
also a string containing DBMS specific syntax to be used after `SET TRANSACTION ISOLATION LEVEL`.
If not specified (`null`) the isolation level will not be set explicitly and the DBMS default will be used.

> Note: This setting does not work for PostgreSQL, where setting the isolation level before the transaction
has no effect. You have to call [[setIsolationLevel()]] in this case after the transaction has started.

> Note: Some DBMS allow setting of the isolation level only for the whole connection so subsequent transactions
may get the same isolation level even if you did not specify any. When using this feature
you may need to set the isolation level for all transactions explicitly to avoid conflicting settings.
At the time of this writing affected DBMS are MSSQL and SQLite.

[isolation level]: http://en.wikipedia.org/wiki/Isolation_%28database_systems%29#Isolation_levels
@return ExtendedPromiseInterface|LazyPromiseInterface