本文整理汇总了PHP中Phosphorum\Models\Users::findFirstByLogin方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::findFirstByLogin方法的具体用法?PHP Users::findFirstByLogin怎么用?PHP Users::findFirstByLogin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phosphorum\Models\Users
的用法示例。
在下文中一共展示了Users::findFirstByLogin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: viewAction
/**
* Shows the user profile
*
* @param int $id User id
* @param string $username User name
*/
public function viewAction($id, $username)
{
$user = $id ? Users::findFirstById($id) : Users::findFirstByLogin($username);
if (!$user) {
$user = Users::findFirstByName($username);
}
if (!$user) {
$this->flashSession->error('The user does not exist');
$this->response->redirect();
return;
}
$this->view->setVar('user', $user);
$parametersNumberPosts = ['users_id = ?0 AND deleted = 0', 'bind' => [$user->id]];
$this->view->setVar('numberPosts', Posts::count($parametersNumberPosts));
$parametersNumberReplies = ['users_id = ?0', 'bind' => [$user->id]];
$this->view->setVar('numberReplies', PostsReplies::count($parametersNumberReplies));
$parametersActivities = ['users_id = ?0', 'bind' => [$user->id], 'order' => 'created_at DESC', 'limit' => 15];
$this->view->setVar('activities', Activities::find($parametersActivities));
$users = Users::find(['columns' => 'id', 'conditions' => 'karma != 0', 'order' => 'karma DESC']);
$ranking = count($users);
foreach ($users as $position => $everyUser) {
if ($everyUser->id == $user->id) {
$ranking = $position + 1;
break;
}
}
$this->gravatar->setSize(220);
$this->view->setVars(['ranking' => $ranking, 'total_ranking' => count($users), 'avatar' => $this->gravatar->getAvatar($user->email)]);
$this->tag->setTitle('Profile - ' . $this->escaper->escapeHtml($user->name));
}
示例2: userAction
/**
* Shows the user profile
*/
public function userAction($id, $username)
{
if ($id) {
$user = Users::findFirstById($id);
} else {
$user = Users::findFirstByLogin($username);
if (!$user) {
$user = Users::findFirstByName($username);
}
}
if (!$user) {
$this->flashSession->error('The user does not exist');
return $this->response->redirect();
}
$this->view->user = $user;
$parametersNumberPosts = array('users_id = ?0 AND deleted = 0', 'bind' => array($user->id));
$this->view->numberPosts = Posts::count($parametersNumberPosts);
$parametersNumberReplies = array('users_id = ?0', 'bind' => array($user->id));
$this->view->numberReplies = PostsReplies::count($parametersNumberReplies);
$parametersActivities = array('users_id = ?0', 'bind' => array($user->id), 'order' => 'created_at DESC', 'limit' => 15);
$this->view->activities = Activities::find($parametersActivities);
$users = Users::find(array('columns' => 'id', 'conditions' => 'karma != 0', 'order' => 'karma DESC'));
$ranking = count($users);
foreach ($users as $position => $everyUser) {
if ($everyUser->id == $user->id) {
$ranking = $position + 1;
break;
}
}
$this->view->ranking = $ranking;
$this->view->total_ranking = count($users);
$this->tag->setTitle('Profile - ' . $this->escaper->escapeHtml($user->name));
}