public function delete($key) { $this->model->setCondition("namespace", $this->namespace); $this->model->setCondition("key", $key); Sabel_Db_Transaction::activate(); try { $this->model->delete(); Sabel_Db_Transaction::commit(); } catch (Exception $e) { Sabel_Db_Transaction::rollback(); } }
public function invoke(Sabel_Aspect_MethodInvocation $inv) { Sabel_Db_Transaction::activate(); try { $result = $inv->proceed(); Sabel_Db_Transaction::commit(); return $result; } catch (Exception $e) { Sabel_Db_Transaction::rollback(); l($e->getMessage(), SBL_LOG_ERR); throw $e; } }
/** * @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; } }
public function testCommit() { Sabel_Db_Transaction::activate(Sabel_Db_Transaction::SERIALIZABLE); $gp = MODEL("Grandparents"); $gp->insert(array("id" => 3, "value" => "grandparents3")); $gp->insert(array("id" => 4, "value" => "grandparents4")); Sabel_Db_Transaction::commit(); $this->assertEquals(4, $gp->getCount()); }
public function delete($key) { $result = null; Sabel_Db_Transaction::activate(); try { if ($model = $this->fetch($key, true)) { if (($timeout = (int) $model->timeout) !== 0) { if ($timeout > time()) { $result = unserialize(str_replace("\\000", "", $model->value)); } } $model->delete(); } Sabel_Db_Transaction::commit(); } catch (Exception $e) { Sabel_Db_Transaction::rollback(); throw $e; } return $result; }
/** * @return void */ public static function clear() { self::$active = false; self::$transactions = array(); self::$isolationLevel = null; }