本文整理匯總了PHP中Model\User::Instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::Instance方法的具體用法?PHP User::Instance怎麽用?PHP User::Instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model\User
的用法示例。
在下文中一共展示了User::Instance方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: login
/**
* To login account.
*
* @param string $username User name.
* @param string $password User password.
*
* @return response array(session, user array).
*/
public function login($username, $password)
{
$model = \Model\User::Instance();
if ($error = $model->validate(array('username' => $username, 'password' => $password)) != "") {
$this->response['error'] = $error;
return $this->response;
}
$user = $model->find(array('username' => $username));
if (!$user) {
$this->response['error'] = "Sorry, no this user";
return $this->response;
}
if ($user['password'] != $password) {
$this->response['error'] = "Sorry, username or password is wrong.";
return $this->response;
}
$response['user'] = $user;
$response['session'] = 'testtestse';
// 這裏會修改, 以後數據層不再負責session 會話.
$this->response['data'] = $response;
return $this->response;
}
示例2: getUsers
/**
* 獲取用戶列表..
*
* @param array $userId 用戶Id.
*
* @return array
*/
public function getUsers($userId)
{
$model = \Model\User::Instance();
$user = $model->getAlbumWithCoverByIds($userId);
return $user;
}