當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Users::findFirstByName方法代碼示例

本文整理匯總了PHP中Phosphorum\Models\Users::findFirstByName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Users::findFirstByName方法的具體用法?PHP Users::findFirstByName怎麽用?PHP Users::findFirstByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Phosphorum\Models\Users的用法示例。


在下文中一共展示了Users::findFirstByName方法的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::findFirstByName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。