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


PHP User::find方法代碼示例

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


在下文中一共展示了User::find方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getUser

 /**
  * Finds user by id.
  *
  * @return User|null User instance
  */
 protected function getUser()
 {
     if ($this->_user === null) {
         $this->_user = User::find()->where(['id' => Yii::$app->user->identity->id])->active()->one();
     }
     return $this->_user;
 }
開發者ID:artkost,項目名稱:yii2-starter-kit,代碼行數:12,代碼來源:Password.php

示例2: getUsersFoundCod

 protected function getUsersFoundCod()
 {
     $user = User::find()->where(['cod' => $this->codUser])->one();
     if (isset($user)) {
         return $user->id;
     } else {
         return 0;
     }
 }
開發者ID:kvaxminsk,項目名稱:belpharma2,代碼行數:9,代碼來源:OrdersHandlerSearch.php

示例3: search

 /**
  * Searches users.
  * @param array $params search query data
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'DATE_FORMAT(FROM_UNIXTIME(created_at), "%Y-%m-%d")', $this->created_at])->andFilterWhere(['like', 'DATE_FORMAT(FROM_UNIXTIME(updated_at), "%Y-%m-%d")', $this->updated_at]);
     return $dataProvider;
 }
開發者ID:bariew,項目名稱:sitown,代碼行數:15,代碼來源:UserSearch.php

示例4: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'role' => $this->role, 'status' => $this->status, 'FROM_UNIXTIME(created_at, "%d.%m.%Y")' => $this->created_at]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'role', $this->role])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
開發者ID:akula22,項目名稱:fifa,代碼行數:18,代碼來源:SearchUser.php

示例5: actionAjaxUser

 /**
  * @return array
  */
 public function actionAjaxUser()
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $result = ['more' => false, 'results' => []];
     $search = \Yii::$app->request->get('search', []);
     if (!empty($search['term'])) {
         $query = User::find()->select('id, username, first_name, email')->where(['like', 'username', trim($search['term'])])->orWhere(['like', 'email', trim($search['term'])])->orWhere(['like', 'first_name', trim($search['term'])])->asArray();
         $result['results'] = array_values($query->all());
     }
     return $result;
 }
開發者ID:tqsq2005,項目名稱:dotplant2,代碼行數:14,代碼來源:BackendCustomerController.php

示例6: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'followers' => $this->followers, 'following' => $this->following, 'photos' => $this->photos, 'avatar_sid' => $this->avatar_sid, 'status' => $this->status, 'last_visit_at' => $this->last_visit_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'last_login_ip', $this->last_login_ip]);
     return $dataProvider;
 }
開發者ID:hackvijay,項目名稱:yii-qa,代碼行數:18,代碼來源:UserAdmin.php

示例7: actionRemoveOverdue

 public function actionRemoveOverdue()
 {
     foreach (User::find()->overdue($this->module->emailConfirmUserExpire)->each() as $user) {
         /** @var User $user */
         $this->stdout($user->username . ' - ' . $user->email);
         $user->delete();
         $this->stdout('OK', Console::FG_GREEN, Console::BOLD);
         $this->stdout(PHP_EOL);
     }
     $this->stdout('Done!', Console::FG_GREEN, Console::BOLD);
     $this->stdout(PHP_EOL);
 }
開發者ID:knyazushka,項目名稱:z34lot.new,代碼行數:12,代碼來源:CronController.php

示例8: actionRemoveOverdue

 /**
  * Removes non-activated expired users
  */
 public function actionRemoveOverdue()
 {
     foreach (User::find()->overdue(Yii::$app->params['user.emailConfirmUserExpire'])->each() as $user) {
         /** @var User $user */
         $this->stdout($user->username);
         $user->delete();
         $this->stdout(' OK', Console::FG_GREEN, Console::BOLD);
         $this->stdout(PHP_EOL);
     }
     $this->stdout('Done!', Console::FG_GREEN, Console::BOLD);
     $this->stdout(PHP_EOL);
 }
開發者ID:maxneh,項目名稱:oripro,代碼行數:15,代碼來源:CronController.php

示例9: findModel

 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (is_numeric($id)) {
         $model = User::findOne($id);
     } else {
         $model = User::find()->where(['username' => $id])->one();
     }
     if ($model !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
開發者ID:xingcuntian,項目名稱:iisns,代碼行數:20,代碼來源:ViewController.php

示例10: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token]);
     return $dataProvider;
 }
開發者ID:rocketyang,項目名稱:huajuan,代碼行數:21,代碼來源:UserSearch.php

示例11: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'marital' => $this->marital, 'birthday' => $this->birthday, 'post_id' => $this->post_id, 'department_id' => $this->department_id, 'user_id' => $this->user_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'visited_at' => $this->visited_at, 'views' => $this->views, 'weight' => $this->weight, 'status_id' => $this->status_id]);
     $query->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'patronymic', $this->patronymic])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'token', $this->token])->andFilterWhere(['like', 'email_confirm_token', $this->email_confirm_token])->andFilterWhere(['like', 'phone_work', $this->phone_work])->andFilterWhere(['like', 'phone_private', $this->phone_private])->andFilterWhere(['like', 'email_work', $this->email_work])->andFilterWhere(['like', 'email_private', $this->email_private]);
     return $dataProvider;
 }
開發者ID:obedkin,項目名稱:atlant,代碼行數:21,代碼來源:UserSearch.php

示例12: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => false]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['status' => $this->status]);
     $query->andFilterWhere(['like', 'email', $this->email]);
     $query->andFilterWhere(['like', 'username', $this->username]);
     return $dataProvider;
 }
開發者ID:goncharovln,項目名稱:keywords,代碼行數:22,代碼來源:UserSearch.php

示例13: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['>=', 'created_at', $this->created_at ? strtotime($this->created_at . ' 00:00:00') : null])->andFilterWhere(['<=', 'created_at', $this->created_at ? strtotime($this->created_at . ' 23:59:59') : null]);
     return $dataProvider;
 }
開發者ID:head26,項目名稱:parsek,代碼行數:23,代碼來源:SearchUser.php

示例14: actionRemoveOverdue

 /**
  * Removes non-activated expired users
  */
 public function actionRemoveOverdue()
 {
     foreach (User::find()->overdue($this->module->emailConfirmTokenExpire)->each() as $user) {
         /** @var User $user */
         $this->stdout($user->username);
         if ($user->delete()) {
             Yii::info('Remove expired user ' . $user->username);
             $this->stdout(' OK', Console::FG_GREEN, Console::BOLD);
         } else {
             Yii::warning('Cannot remove expired user ' . $user->username);
             $this->stderr(' FAIL', Console::FG_RED, Console::BOLD);
         }
         $this->stdout(PHP_EOL);
     }
     $this->stdout('Done!', Console::FG_GREEN, Console::BOLD);
     $this->stdout(PHP_EOL);
 }
開發者ID:oke11o,項目名稱:seokeys,代碼行數:20,代碼來源:CronController.php

示例15:

/*$listdata = ArrayHelper::map(Post::find()->all(), 'id', 'title'); ?>
  <?= $form->field($model, 'post_id')->dropDownList($listdata, [
      'class' => 'form-control select',
      'prompt' => Yii::t('app', 'Select from list')
  ]); */
?>

        <?php 
$listdata = ArrayHelper::map(Department::find()->all(), 'id', 'title');
?>
        <?php 
echo $form->field($model, 'department_id')->dropDownList($listdata, ['class' => 'form-control select', 'prompt' => Yii::t('app', 'Select from list')]);
?>

        <?php 
$listdata = ArrayHelper::map(User::find()->all(), 'id', 'last_name');
?>
        <?php 
echo $form->field($model, 'user_id')->dropDownList($listdata, ['class' => 'form-control select', 'prompt' => Yii::t('app', 'Select from list')]);
?>


        <?php 
$listdata = ArrayHelper::map(Address::find()->all(), 'id', 'title');
?>
        <?php 
echo $form->field($model, 'address_id')->dropDownList($listdata, ['class' => 'form-control select', 'prompt' => Yii::t('app', 'Select from list')]);
?>

        <?php 
echo $form->field($model, 'place_id')->widget(DepDrop::classname(), ['options' => ['id' => 'place_id'], 'pluginOptions' => ['depends' => ['user-address_id'], 'placeholder' => 'Select...', 'url' => Url::to(['/place/list'])]]);
開發者ID:obedkin,項目名稱:atlant,代碼行數:31,代碼來源:_form.php


注:本文中的app\modules\user\models\User::find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。