Пример #1
0
 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();
     }
 }
Пример #2
0
 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;
     }
 }
Пример #3
0
 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;
     }
 }
Пример #4
0
 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;
 }
Пример #5
0
 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());
 }