src/Driver.php
public function inTransaction(callable $function)
    {
        if (!is_callable($function)) {
            throw new InvalidArgumentException('$function must be callable.');
        }
        $this->beginTransaction();
        try {
            if (func_num_args() === 1) {
                $returnValue = $function($this);
            } else {
                $args    = func_get_args();
                $args[0] = $this;
                $returnValue = call_user_func_array($function, $args);
            }
            $this->commit();
            return $returnValue;
        } catch (\PDOException $e) {
            $this->rollBack();
            throw $e;
        }
    }
public function inTransaction(callable $function)
    {
        if (!is_callable($function)) {
            throw new InvalidArgumentException('$function must be callable.');
        }
        $this->beginTransaction();
        try {
            if (func_num_args() === 1) {
                $returnValue = $function($this);
            } else {
                $args    = func_get_args();
                $args[0] = $this;
                $returnValue = call_user_func_array($function, $args);
            }
            $this->commit();
            return $returnValue;
        } catch (\PDOException $e) {
            $this->rollBack();
            throw $e;
        }
    }
public function inTransaction ( callable $ function ) { if ( ! is_callable ( $ function ) ) { throw new InvalidArgumentException ( '$function must be callable.' ) ; } $ this -> beginTransaction ( ) ; try { if ( func_num_args ( ) === 1 ) { $ returnValue = $ function ( $ this ) ; } else { $ args = func_get_args ( ) ; $ args [ 0 ] = $ this ; $ returnValue = call_user_func_array ( $ function , $ args ) ; } $ this -> commit ( ) ; return $ returnValue ; } catch ( \ PDOException $ e ) { $ this -> rollBack ( ) ; throw $ e ; } }
Call a function guarded by a transaction.

@param callable $function The function to guard. First argument is the driver, the rest are the arguments
passed to the method.

@return mixed The return value of the guarded function
Call a function guarded by a transaction .