예제 #1
0
 /**
  * 删除用户
  * 只用于单元测试
  */
 public function deleteUserByAccount($account)
 {
     $this->db->beginTransaction();
     try {
         $res = Sql::select('uid')->from('uc_members')->where('username=?', $account)->forUpdate()->get($this->db);
         if (count($res) == 0) {
             $this->db->rollBack();
             return false;
         }
         $uid = $res[0]['uid'];
         Sql::deleteFrom('pre_common_member_profile')->where('uid=?', $uid)->exec($this->db);
         Sql::deleteFrom('uc_members')->where('uid=?', $uid)->exec($this->db);
         $this->db->commit();
     } catch (Exception $e) {
         $this->db->rollBack();
         throw $e;
     }
     return true;
 }
예제 #2
0
파일: SqlTest.php 프로젝트: ziyanziyu/ezsql
 public function testDelete3()
 {
     // DELETE FROM tab WHERE a=1 ORDER BY b LIMIT 1
     $this->db->setExpected('DELETE FROM tab WHERE a=? ORDER BY b LIMIT 1', 1);
     Sql::deleteFrom('tab')->where('a=?', 1)->orderBy('b')->limit(1)->exec($this->db);
 }