当前位置: 首页>>代码示例>>PHP>>正文


PHP Users::findFirstByLogin方法代码示例

本文整理汇总了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));
 }
开发者ID:huoybb,项目名称:forum,代码行数:36,代码来源:UsersController.php

示例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));
 }
开发者ID:kjmtrue,项目名称:phalcon-tip,代码行数:36,代码来源:DiscussionsController.php


注:本文中的Phosphorum\Models\Users::findFirstByLogin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。