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


PHP User::find方法代码示例

本文整理汇总了PHP中frontend\models\User::find方法的典型用法代码示例。如果您正苦于以下问题:PHP User::find方法的具体用法?PHP User::find怎么用?PHP User::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在frontend\models\User的用法示例。


在下文中一共展示了User::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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 return 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', 'user_type', $this->user_type])
            ->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', 'email', $this->email]);

        return $dataProvider;
    }
开发者ID:seans888,项目名称:SMF-Project,代码行数:39,代码来源:UserSearch.php

示例2: myValidatePassword

 /**
  * @param $attribute
  * @param $params
  * @return bool
  */
 public function myValidatePassword($attribute, $params)
 {
     $model = User::find()->where(['username' => $this->username])->andWhere(['status' => 1])->one();
     if (!empty($model) && $model->setPassword($this->{$attribute}) == $model->password) {
         return true;
     }
     $this->addError($attribute, 'The username or password is error!');
 }
开发者ID:MarketPlaceDaniel,项目名称:WangYi,代码行数:13,代码来源:UserLoginForm.php

示例3: validateOriginalPassword

 /**
  * @param $attribute
  * @param $params
  * @return bool
  */
 public function validateOriginalPassword($attribute, $params)
 {
     $model = User::find()->where(['username' => Yii::$app->session['username']])->one();
     if (!empty($model) && $this->{$attribute} == $model->password) {
         return true;
     }
     $this->addError($attribute, 'The original password is error!');
 }
开发者ID:djc1103617718,项目名称:WangYi,代码行数:13,代码来源:UserTest.php

示例4: findModelByUsername

 /**
  * @return array|null|\yii\db\ActiveRecord
  * @throws NotFoundHttpException
  */
 public static function findModelByUsername()
 {
     if ($username = Yii::$app->session['__username']) {
         if (($model = User::find()->where(['username' => $username])->one()) !== null) {
             return $model;
         }
     }
     throw new NotFoundHttpException('The requested page does not exist.');
 }
开发者ID:MarketPlaceDaniel,项目名称:WangYi,代码行数:13,代码来源:User.php

示例5: actionCreate

 /**
  * Creates a new Post model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Post();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'category' => Category::find()->all(), 'authors' => User::find()->all()]);
     }
 }
开发者ID:Atsumoriso,项目名称:Yii,代码行数:14,代码来源:PostController.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]);
     $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;
     }
     $query->andFilterWhere(['like', '_id', $this->_id])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'user_role', $this->user_role])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'created_at', $this->created_at])->andFilterWhere(['like', 'updated_at', $this->updated_at]);
     return $dataProvider;
 }
开发者ID:jaibabu9,项目名称:987654321,代码行数:20,代码来源:UserSearch.php

示例7: actionCreate

 /**
  * @return \yii\web\Response
  */
 public function actionCreate()
 {
     $model = new Comment();
     $model->ip = Yii::$app->request->userIP;
     $model->username = Yii::$app->session['__username'];
     $model->user_id = User::find()->where(['username' => $model->username])->one()->id;
     $model->created_at = time();
     $model->updated_at = time();
     //$params = FilterForm::filterHtml();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['show/view', 'id' => $model->news_id]);
     }
     echo '发布失败,请重新发表评论!';
 }
开发者ID:MarketPlaceDaniel,项目名称:WangYi,代码行数:17,代码来源:CommentController.php

示例8: search

 /**
  * @param $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find()->orderBy('created_at DESC');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if ($this->created_at !== null) {
         $date = strtotime($this->created_at);
         $query->andFilterWhere(['between', 'created_at', $date, $date + 3600 * 24]);
     }
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['registration_ip' => $this->registration_ip]);
     return $dataProvider;
 }
开发者ID:buuug7,项目名称:game4039,代码行数:19,代码来源:FrontendUserSearch.php

示例9: 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, 'role' => $this->role, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'fname', $this->fname])->andFilterWhere(['like', 'lname', $this->lname])->andFilterWhere(['like', 'contact_no', $this->contact_no])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'company_name', $this->company_name])->andFilterWhere(['like', 'company_description', $this->company_description])->andFilterWhere(['like', 'shipping_address', $this->shipping_address])->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', 'email', $this->email]);
     return $dataProvider;
 }
开发者ID:pdbangibang,项目名称:apc-softdev-gd121mi122-4,代码行数:21,代码来源:UserSearch.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 return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'role' => $this->role, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'data_nasc' => $this->data_nasc]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'nome', $this->nome])->andFilterWhere(['like', 'sexo', $this->sexo])->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', 'endereco', $this->endereco])->andFilterWhere(['like', 'complemento', $this->complemento])->andFilterWhere(['like', 'instituicao', $this->instituicao])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'grupoacesso', $this->grupoacesso])->andFilterWhere(['like', 'cpf', $this->cpf]);
     return $dataProvider;
 }
开发者ID:rsoaresgouveia,项目名称:SiGePolo,代码行数:21,代码来源:UserSearch.php

示例11: findByUsername

 /**
  * Finds user by username
  *
  * @param  string      $username
  * @return static|null
  */
 public static function findByUsername($username)
 {
     $user = User::find()->where(['username' => $username])->asArray()->one();
     if ($user) {
         return new static($user);
     }
     return null;
     /*foreach (self::$users as $user) {
                 if (strcasecmp($user['username'], $username) === 0) {
                     return new static($user);
                 }
             }
     
             return null;*/
 }
开发者ID:jia253,项目名称:centosYii2,代码行数:21,代码来源:User.php

示例12: 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]);
     $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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'mobile_number' => $this->mobile_number, 'mobileNumber' => $this->mobileNumber]);
     $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', 'email', $this->email])->andFilterWhere(['like', 'addressImage', $this->addressImage]);
     return $dataProvider;
 }
开发者ID:arfo90,项目名称:fp-app,代码行数:23,代码来源:UserSearch.php

示例13: steamAuth

 /**
  * Authencticate or create and authenticate user
  *
  * @param \frontend\components\SteamAuth $client
  */
 public function steamAuth($client)
 {
     $user = User::find()->where(['steamid' => $client->steamId])->one();
     if (Yii::$app->user->isGuest) {
         if ($user) {
             Yii::$app->user->login($user);
             return $this->redirect(['site/index']);
         }
         $user = User::createSteamUser($client);
         if (!$user) {
             throw new Exception("Не получилось создать пользователя :(", 500);
         }
         return $this->redirect(['site/index']);
     }
     return $this->redirect(['site/index']);
 }
开发者ID:stmswitcher,项目名称:d3-santa,代码行数:21,代码来源:SiteController.php

示例14: 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 return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     if (Yii::$app->user->identity->rol_id == '2') {
         $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'rol_id' => $this->rol_id, 'supervisor' => $this->supervisor, 'id_organizacion' => $this->id_organizacion, 'id_empresa' => $this->id_empresa, 'id_distrito' => $this->id_distrito])->orderBy(['username' => SORT_ASC]);
     } else {
         $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'rol_id' => '1', 'supervisor' => $this->supervisor, 'id_organizacion' => $this->id_organizacion, 'id_empresa' => $this->id_empresa, 'id_distrito' => $this->id_distrito])->orderBy(['username' => SORT_ASC]);
     }
     $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', 'email', $this->email])->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'apellido', $this->apellido])->andFilterWhere(['like', 'cedula', $this->cedula]);
     return $dataProvider;
 }
开发者ID:noeliovando,项目名称:yii2advance,代码行数:25,代码来源:UserSearch.php

示例15: beforeSave

 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         // ...custom code here..
         //unread初始值为所有接收人,添加未阅读的用户id
         if ($insert) {
             $user = User::find()->select('id')->asArray()->all();
             $user = ArrayHelper::getColumn($user, 'id');
             $this->unread = implode(',', $user);
             //将deleted初始值设置为0,防止该字段为null
             $this->deleted = 0;
         }
         //...custom code end
         return true;
     } else {
         return false;
     }
 }
开发者ID:buuug7,项目名称:game4039,代码行数:18,代码来源:Message.php


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