/** * @param Sabel_Db_Driver $driver * * @throws Sabel_Db_Exception_Connection * @return void */ public static function connect(Sabel_Db_Driver $driver) { if (Sabel_Db_Transaction::isActive()) { $connectionName = $driver->getConnectionName(); if ($connection = Sabel_Db_Transaction::getConnection($connectionName)) { $driver->setConnection($connection); } else { Sabel_Db_Transaction::begin(self::_connect($driver)); } $driver->autoCommit(false); } else { self::_connect($driver); } }
public function invoke(Sabel_Aspect_MethodInvocation $inv) { if (!($active = Sabel_Db_Transaction::isActive())) { Sabel_Db_Transaction::activate(); } try { $result = $inv->proceed(); if (!$active) { Sabel_Db_Transaction::commit(); } return $result; } catch (Exception $e) { if (!$active) { Sabel_Db_Transaction::rollback(); } throw $e; } }