Exemple #1
0
 public function __destruct()
 {
     // If we rolled back then the transaction would have already been popped.
     if (!$this->rolledBack) {
         $this->connection->popTransaction($this->name);
     }
 }
Exemple #2
0
 public function popTransaction($name)
 {
     if ($this->savepointSupport) {
         return parent::popTransaction($name);
     }
     if (!$this->supportsTransactions()) {
         return;
     }
     if (!$this->inTransaction()) {
         throw new TransactionNoActiveException();
     }
     // Commit everything since SAVEPOINT $name.
     while ($savepoint = array_pop($this->transactionLayers)) {
         if ($savepoint != $name) {
             continue;
         }
         // If there are no more layers left then we should commit or rollback.
         if (empty($this->transactionLayers)) {
             // If there was any rollback() we should roll back whole transaction.
             if ($this->willRollback) {
                 $this->willRollback = FALSE;
                 $this->connection->rollBack();
             } elseif (!$this->connection->commit()) {
                 throw new TransactionCommitFailedException();
             }
         } else {
             break;
         }
     }
 }