예제 #1
0
파일: Database.php 프로젝트: reoring/sabel
 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
 /**
  * @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);
     }
 }
예제 #4
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;
     }
 }
예제 #5
0
파일: Test.php 프로젝트: reoring/sabel
 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());
 }
예제 #6
0
파일: Database.php 프로젝트: reoring/sabel
 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;
 }
예제 #7
0
 /**
  * @return void
  */
 public static function clear()
 {
     self::$active = false;
     self::$transactions = array();
     self::$isolationLevel = null;
 }