Start a transaction in the database.

@param  callable $cb
@return QueryBuilder
3770
public function transition(callable $cb)
    {
        $where = $this->where;

        $data = $this->get();

        if (call_user_func_array($cb, [$data]) === true) {
            $this->where = $where;
        }

        return $this;
    }
746756
public function sort(callable $cb = null)
    {
        if ($cb) {
            // Custom searches can be easier on memory, but run absurdly slow
            // pre PHP7
            if (PHP_MAJOR_VERSION < 7) {
                return $this->arraySort($cb);
            }
            return $this->mergeSort($cb);
        }
        return $this->arraySort();
    }
1038949
public function beginTransaction() : bool
    {
        if ($this->dbconn->inTransaction()) {
            throw new TransactionErrorException("A transaction has already been started.");
        }
        try {
            return $this->dbconn->beginTransaction();
        } catch (\PDOException $exception) {
            throw new TransactionsNotSupportedException("Transactions are not supported in this database.");
        }
    }
160767
public function startTransaction($transactionId = '')
    {
        $this->logger->debug(__FUNCTION__, 'Input Transaction ID: ' . json_encode($transactionId));
        if (empty($transactionId)) {
            $transactionId = date('YmdHis') . rand(100000, 999999);
        }
        $this->transactionId = $transactionId;
        $this->logger->debug(__FUNCTION__, 'Output Transaction ID: ' . json_encode($this->transactionId));

        return $this;
    }
612495
public function begin()
    {
        $this->current = $this->current instanceof Transaction
            ? $this->current->newTransaction()
            : new Transaction;
    }
1274780
public function transaction(\Closure $callback): Transaction
    {
        /**
         * Get the Transaction class
         *
         * @var \Pecee\Pixie\QueryBuilder\Transaction $queryTransaction
         * @throws \Exception
         */
        $queryTransaction = new Transaction($this->connection);
        $queryTransaction->statements = $this->statements;

        try {
            // Begin the PDO transaction
            if ($this->pdo()->inTransaction() === false) {
                $this->pdo()->beginTransaction();
            }

            // Call closure - this callback will return TransactionHaltException if user has already committed the transaction
            $callback($queryTransaction);

            // If no errors have been thrown or the transaction wasn't completed within the closure, commit the changes
            $this->pdo()->commit();

        } catch (TransactionHaltException $e) {

            // Commit or rollback behavior has been triggered in the closure
            return $queryTransaction;

        } catch (\Exception $e) {

            // Something went wrong. Rollback and throw Exception
            if ($this->pdo()->inTransaction() === true) {
                $this->pdo()->rollBack();
            }

            throw Exception::create($e, $this->getConnection()->getAdapter()->getQueryAdapterClass(), $this->getLastQuery());
        }

        return $queryTransaction;
    }
1358427
public function begin($transactionId = null)
    {
        return $this->client->sendFrame($this->getProtocol()->getBeginFrame($transactionId));
    }
608472
protected function begin_transaction() {
        // Recordsets do not work well with transactions in SQL Server,
        // let's prefetch the recordsets to memory to work around these problems.
        foreach ($this->recordsets as $rs) {
            $rs->transaction_starts();
        }

        $this->query_start('native sqlsrv_begin_transaction', NULL, SQL_QUERY_AUX);
        $result = sqlsrv_begin_transaction($this->sqlsrv);
        $this->query_end($result);
    }
827152
public function begin() {
        if ($this->transactionLevel < 0) throw new RuntimeException('Negative transaction nesting level detected: '.$this->transactionLevel);

        if (!$this->transactionLevel)
            $this->execute('start transaction');

        $this->transactionLevel++;
        return $this;
    }
431933
public function callback($callback)
    {
        $t = $this;
        $args = array_slice(func_get_args(),1);

        // use an event handler to dispatch to the callback
        $this->_events->register('startTransaction', function($event, $connection) use ($t, $callback, $args) {
            $t->results []= call_user_func_array($callback, $args);
        });

        return $this;
    }
31759
public function groupStart(): QueryBuilderInterface
	{
		$conj = empty($this->state->getQueryMap()) ? ' WHERE ' : ' ';

		$this->state->appendMap($conj, '(', 'group_start');

		return $this;
	}
305138
public function callable(callable $callable): BaseQueryRelateContract
    {
        $query = call_user_func($callable, $this->query);
        if ($query instanceof Builder) {
            $this->query = $query;
        }

        return $this;
    }
569539
public function transaction() {

		if(null === $this -> connection) {
			$this -> connect();
		}

		$this -> connection -> autocommit(false);
		$this -> connection -> begin_transaction(MYSQLI_TRANS_START_READ_WRITE);

		return $this;
	}
1184567
public function beginTransaction()
    {
        if (! $this->isValid()) return;

        foreach ($this->getConnections() as $connection) {
            if (! $connection->inTx()) $connection->beginTransaction();
        }
    }
1225742
function begin() {
		$this->dbh or $this->setup();

		if ($this->savepoint == 0) {
			$this->dbh->beginTransaction();
		}
		else { // already in a transaction
			$this->dbh->exec('SAVEPOINT save'.$this->savepoint);
		}

		$this->savepoint++;
		return $this;
	}
248066
public HibernateTransaction start()
	{
		final Session session = sessionProvider.get();
		final Transaction tx = session.beginTransaction();

		return new HibernateTransaction(tx);
	}
1263117
protected function beginTransaction()
    {
        $modelClass = $this->modelClass;
        $transaction = $modelClass::getDb()->beginTransaction();

        $this->_transaction[] = $transaction;
    }