* fix the bug of 21bird.

This commit is contained in:
wangchunsheng
2010-02-27 03:17:23 +00:00
parent c03b4f07e2
commit 907baa748b
+6 -4
View File
@@ -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;
}