From cf3fbc6824a8df1ce4ca5e2cc255822e1c67c20d Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Sat, 27 Feb 2010 03:17:23 +0000 Subject: [PATCH] * fix the bug of 21bird. --- trunk/module/user/model.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/trunk/module/user/model.php b/trunk/module/user/model.php index 7c6a4c5c0b..4eaf603c56 100644 --- a/trunk/module/user/model.php +++ b/trunk/module/user/model.php @@ -71,10 +71,12 @@ class userModel extends model /* 通过id获取某一个用户的信息。*/ public function getById($userID) { - $where = $userID > 0 ? " WHERE id = '$userID'" : " WHERE account = '$userID'"; - $sql = "SELECT * FROM " . TABLE_USER . $where; - $user = $this->dbh->query($sql)->fetch(); - if($user) $user->last = date('Y-m-d H:i:s', $user->last); + $user = $this->dao->select('*')->from(TABLE_USER) + ->onCaseOf(is_int($userID))->where('id')->eq((int)$userID)->endCase() + ->onCaseOf(is_string($userID))->where('account')->eq($userID)->endCase() + ->fetch(); + if(!$user) return false; + $user->last = date('Y-m-d H:i:s', $user->last); return $user; }