当前位置: 首页>>代码示例>>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;未经允许,请勿转载。