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; } }
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 testRollback() { Sabel_Db_Transaction::activate(); $gp = MODEL("Grandparents"); $gp->insert(array("id" => 3, "value" => "grandparents3")); $gp->insert(array("id" => 4, "value" => "grandparents4")); Sabel_Db_Transaction::rollback(); $this->assertEquals(2, $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; }