本文整理汇总了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;
}