X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fgabordemooij%2Fredbean%2FRedBeanPHP%2FUtil%2FTransaction.php;fp=vendor%2Fgabordemooij%2Fredbean%2FRedBeanPHP%2FUtil%2FTransaction.php;h=0000000000000000000000000000000000000000;hp=35e70f8f0998039d2dfc097a9aaae1e9ec97f7bd;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/gabordemooij/redbean/RedBeanPHP/Util/Transaction.php b/vendor/gabordemooij/redbean/RedBeanPHP/Util/Transaction.php deleted file mode 100644 index 35e70f8f0..000000000 --- a/vendor/gabordemooij/redbean/RedBeanPHP/Util/Transaction.php +++ /dev/null @@ -1,90 +0,0 @@ - - * $from = 1; - * $to = 2; - * $amount = 300; - * - * R::transaction(function() use($from, $to, $amount) - * { - * $accountFrom = R::load('account', $from); - * $accountTo = R::load('account', $to); - * $accountFrom->money -= $amount; - * $accountTo->money += $amount; - * R::store($accountFrom); - * R::store($accountTo); - * }); - * - * - * @param Adapter $adapter Database Adapter providing transaction mechanisms. - * @param callable $callback Closure (or other callable) with the transaction logic - * - * @return mixed - */ - public static function transaction( Adapter $adapter, $callback ) - { - if ( !is_callable( $callback ) ) { - throw new RedException( 'R::transaction needs a valid callback.' ); - } - - static $depth = 0; - $result = null; - try { - if ( $depth == 0 ) { - $adapter->startTransaction(); - } - $depth++; - $result = call_user_func( $callback ); //maintain 5.2 compatibility - $depth--; - if ( $depth == 0 ) { - $adapter->commit(); - } - } catch ( \Exception $exception ) { - $depth--; - if ( $depth == 0 ) { - $adapter->rollback(); - } - throw $exception; - } - return $result; - } -}