YetORM\Transaction::transaction PHP Метод

transaction() публичный Метод

public transaction ( Closure $callback ) : mixed
$callback Closure
Результат mixed
    public function transaction(\Closure $callback)
    {
        try {
            $this->begin();
            $return = $callback();
            $this->commit();
            return $return;
        } catch (\Exception $e) {
            $this->rollback();
            throw $e;
        }
    }

Usage Example

Пример #1
0
 /**
  * @param  \Closure $callback
  * @return mixed
  */
 protected final function transaction(\Closure $callback)
 {
     try {
         return $this->transaction->transaction($callback);
     } catch (\Exception $e) {
         $this->handleException($e);
         throw $e;
     }
 }