/**
  * {@inheritdoc}
  */
 public function rollback()
 {
     if (!$this->dbalConnection->rollBack()) {
         throw new RollbackException('Cannot rollback Doctrine DBAL transaction');
     }
 }
Exemple #2
0
 /**
  * Cancels any database changes done during the current transaction.
  *
  * @throws \Doctrine\DBAL\ConnectionException If the rollback operation failed.
  */
 public function rollBack()
 {
     if ($this->_transactionNestingLevel == 0) {
         throw ConnectionException::noActiveTransaction();
     }
     $this->connect();
     $logger = $this->_config->getSQLLogger();
     if ($this->_transactionNestingLevel == 1) {
         if ($logger) {
             $logger->startQuery('"ROLLBACK"');
         }
         $this->_transactionNestingLevel = 0;
         $this->_conn->rollBack();
         $this->_isRollbackOnly = false;
         if ($logger) {
             $logger->stopQuery();
         }
         if (false === $this->autoCommit) {
             $this->beginTransaction();
         }
     } elseif ($this->_nestTransactionsWithSavepoints) {
         if ($logger) {
             $logger->startQuery('"ROLLBACK TO SAVEPOINT"');
         }
         $this->rollbackSavepoint($this->_getNestedTransactionSavePointName());
         --$this->_transactionNestingLevel;
         if ($logger) {
             $logger->stopQuery();
         }
     } else {
         $this->_isRollbackOnly = true;
         --$this->_transactionNestingLevel;
     }
 }
 function it_should_throw_an_exception_if_dbal_transaction_rollback_failed(Connection $connection)
 {
     $connection->rollBack()->willReturn(false);
     $this->shouldThrow('\\RemiSan\\TransactionManager\\Exception\\RollbackException')->duringRollback();
 }