Db::rollback PHP Method

rollback() public method

事务回滚
public rollback ( ) : boolen
return boolen
    public function rollback()
    {
        if ($this->transTimes > 0) {
            // $result = mysql_query('ROLLBACK', $this->_linkID);
            $this->transTimes = 0;
            if (!Capsule::getReadPdo()->rollBack()) {
                throw_exception($this->error());
            }
        }
        return true;
    }

Usage Example

Esempio n. 1
0
 public function createSession($user)
 {
     if (empty($user)) {
         return;
     }
     try {
         Db::begin();
         $user->last_login = Db::now();
         $user->store();
         $session = Orm::collection('Session')->load();
         $session->user = $user;
         $session->token = App::hash(uniqid(rand(), true));
         $session->store();
         Db::commit();
     } catch (Exception $e) {
         Db::rollback();
         throw $e;
     }
     return $session->token;
 }
All Usage Examples Of Db::rollback