Ejemplo n.º 1
0
 /**
  * Begin a single transaction.
  *
  * @param Transaction $transaction
  * @return void
  */
 protected function beginTransaction(Transaction $transaction)
 {
     try {
         if (!$transaction->inTransaction()) {
             $transaction->begin();
         }
     } catch (\Exception $e) {
         $errs = new MultiErrors();
         $errs->E_ERROR[] = $e;
         $errs->merge($this->rollbackTransactions());
         throw new MultiException('Unable to begin transaction', $errs);
     }
 }
Ejemplo n.º 2
0
 /**
  * Commit all transactions.
  *
  * @return void
  */
 public function commit()
 {
     if (!$this->inTransaction()) {
         throw new RuntimeException('Cannot commit - not in a transaction');
     }
     try {
         foreach ($this->transactions as $transaction) {
             $transaction->commit();
         }
     } catch (\Exception $e) {
         $errs = new \PEAR2\MultiErrors();
         $errs->E_ERROR[] = $e;
         $errs->merge($this->rollbackTransactions());
         throw new MultiException('ERROR: commit failed', $errs);
     }
 }