/** * 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; }
/** * 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 * * @throws ConnectionException If the rollback operation failed. */ public function rollback() { if ($this->_transactionNestingLevel == 0) { throw ConnectionException::rollbackFailedNoActiveTransaction(); } $this->connect(); if ($this->_transactionNestingLevel == 1) { $this->_transactionNestingLevel = 0; $this->_conn->rollback(); $this->_isRollbackOnly = false; } else { $this->_isRollbackOnly = true; --$this->_transactionNestingLevel; } }