示例#1
0
 public function removeUser(User $model)
 {
     $dbManager = Db::getInstance();
     if ($model->id) {
         $statement = $dbManager->prepare(self::REMOVE_USER_BY_UID);
         $statement->bindValue(1, $model->id, PDO::PARAM_INT);
         // this add to get user's user name
         if (!$model->username) {
             if ($resp = $this->getUser($model)) {
                 return $resp;
             }
         }
     } else {
         if ($model->username) {
             $statement = $dbManager->prepare(self::REMOVE_USER_BY_USERNAME);
             $statement->bindValue(1, $model->username, PDO::PARAM_STR);
         } else {
             return new ApiResponse(Code::FAIL_USER_UID_OR_NAME_NOT_EXISTS, null);
         }
     }
     if (!$statement->execute()) {
         return new ApiResponse(Code::FAIL_DATABASE_ERROR, null);
     }
     JegarnUtil::removeUser($model->username);
     return null;
 }