/** * @inheritdoc * @throws ConnectionException */ public function rollBack() { if ($this->isWrapped && parent::getTransactionNestingLevel() === 1) { throw ConnectionException::noActiveTransaction(); } parent::rollBack(); }
/** * Checks whether the current transaction is marked for rollback only. * * @return boolean * * @throws \Doctrine\DBAL\ConnectionException If no transaction is active. */ public function isRollbackOnly() { if ($this->_transactionNestingLevel == 0) { throw ConnectionException::noActiveTransaction(); } return $this->_isRollbackOnly; }
/** * Cancel any database changes done during a transaction or since a specific * savepoint that is in progress. This function may only be called when * auto-committing is disabled, otherwise it will fail. Therefore, a new * transaction is implicitly started after canceling the pending changes. * * this method can be listened with onPreTransactionRollback and onTransactionRollback * eventlistener methods * * @param string $savepoint Name of a savepoint to rollback to. * @throws Doctrine\DBAL\ConnectionException If the rollback operation fails at database level. * @return boolean FALSE if rollback couldn't be performed, TRUE otherwise. */ public function rollback() { if ($this->_transactionNestingLevel == 0) { throw ConnectionException::rollbackFailedNoActiveTransaction(); } $this->connect(); if ($this->_transactionNestingLevel == 1) { $this->_transactionNestingLevel = 0; $this->_conn->rollback(); } --$this->_transactionNestingLevel; return true; }