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


PHP User::find方法代码示例

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


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

示例1: actionSave

 public function actionSave()
 {
     $accountId = $this->getAccountId();
     $request = Yii::$app->request;
     $operatorId = $request->post('operatorId', '');
     $sampleId = $request->post('sampleId', '');
     $name = $request->post('name', '');
     $quantity = $request->post('quantity', '');
     $imgUrl = $request->post('imgUrl', '');
     $operator = User::find()->where(['_id' => $operatorId])->one();
     if ($operator === null) {
         return ['code' => 1309, 'msg' => 'not login'];
     }
     if ($name == '') {
         return ['code' => 1300, 'msg' => 'name not get'];
     }
     if ($quantity == '') {
         return ['code' => 1300, 'msg' => 'quantity not get'];
     }
     $sample = Sample::find()->where(['_id' => $sampleId])->one();
     if ($sampleId == '' || $sample == null) {
         $sample = new Sample();
         $sample->usedNumber = 0;
     }
     $sample->name = $name;
     $sample->quantity = $quantity;
     $sample->operator = $operator->name;
     $sample->imgUrl = $imgUrl;
     $sample->accountId = $accountId;
     $sample->save();
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     return ['code' => 200, 'msg' => 'OK'];
 }
开发者ID:timelessmemory,项目名称:uhkklp,代码行数:33,代码来源:SampleController.php

示例2: actionStockPedidos

 public function actionStockPedidos($idComercio, $idRutaDiaria)
 {
     $rutaDiaria = RutaDiaria::find()->where(['id' => $idRutaDiaria])->one();
     $usuario = User::find()->where(['id' => $rutaDiaria->id_usuario])->one();
     $rutaDiariaComercio = $this->findRutaDiariaComercio($idComercio, $idRutaDiaria);
     $datosGrillaStock = [];
     $datosGrillaPedidos = [];
     $i = 0;
     if ($rutaDiariaComercio->getStocks()->count() > 0) {
         $datosStock = $this->findStockComercio($rutaDiariaComercio->id);
         foreach ($datosStock as $stock) {
             $nombreProducto = nombreProducto($stock->id_producto);
             $datosGrillaStock[$i] = ['tipo' => Yii::t('core', 'Stock'), 'producto' => $nombreProducto, 'cantidad' => $stock->cantidad];
             $i++;
         }
     }
     $i = 0;
     if ($rutaDiariaComercio->getPedidos()->count() > 0) {
         $datosPedidos = $this->findPedidosComercio($rutaDiariaComercio->id);
         foreach ($datosPedidos as $pedido) {
             $nombrePedido = nombreProducto($pedido->id_producto);
             $datosGrillaPedidos[$i] = ['tipo' => Yii::t('core', 'Order'), 'producto' => $nombrePedido, 'cantidad' => $pedido->cantidad];
             $i++;
         }
     }
     return $this->render('stockPedidos', ['model' => $rutaDiariaComercio, 'datosGrillaStock' => $datosGrillaStock, 'datosGrillaPedidos' => $datosGrillaPedidos, 'fecha' => $rutaDiaria->fecha, 'usuario' => $usuario->username, 'ruta' => $rutaDiaria->id]);
 }
开发者ID:apmauj,项目名称:1f8bf10ab74d6f5ca69f7c07b7ee1c38,代码行数:27,代码来源:RutaDiariaController.php

示例3: getUser

 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->user === false) {
         $this->user = User::find()->andWhere(['or', ['username' => $this->username], ['email' => $this->username]])->one();
     }
     return $this->user;
 }
开发者ID:buuug7,项目名称:game4039,代码行数:12,代码来源:LoginForm.php

示例4: actionIndex

 public function actionIndex()
 {
     $query = User::find();
     $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $query->count()]);
     $countries = $query->orderBy('registerTime DESC')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render(Variable::$userMange_view, ['countries' => $countries, 'pagination' => $pagination]);
 }
开发者ID:jaybril,项目名称:www.mimgpotea.com,代码行数:7,代码来源:UsermangerController.php

示例5: actionShowTo

 public function actionShowTo()
 {
     \Yii::$app->response->format = Response::FORMAT_JSON;
     $id = $_POST['id'];
     $todoList = User::find()->where(['id' => $id])->with('todos')->asArray()->one();
     //print_r($done);
     return $todoList;
 }
开发者ID:Hardronox,项目名称:first-project,代码行数:8,代码来源:UserApiController.php

示例6: isManager

 /**
  * @return bool
  */
 public function isManager()
 {
     $model = User::find()->where(['username' => $this->username])->andWhere(['status' => 1])->one();
     $manager = Manager::find()->where(['user_id' => $model->id, 'status' => 1])->one();
     if ($manager) {
         return true;
     }
     return false;
 }
开发者ID:djc1103617718,项目名称:WangYi,代码行数:12,代码来源:ManagerLoginForm.php

示例7: actionUpdate

 public function actionUpdate()
 {
     $model = User::find()->where(['id' => \App::$app->user->identity->getId()])->One();
     $model->setScenario('admin-update');
     if ($model->load(\App::$app->request->post()) && $model->save()) {
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
开发者ID:wuwenhan,项目名称:huoqiwang,代码行数:10,代码来源:PassController.php

示例8: actionIndex

 /**
  * Lists all User models.
  * @return mixed
  */
 public function actionIndex()
 {
     if (!$this->is_access('user/index')) {
         Yii::$app->session->setFlash('error', $this->errorInfo);
         return $this->redirect($this->redirectUrl);
     }
     $dataProvider = new ActiveDataProvider(['query' => User::find()->where(['<>', 'id', '1']), 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     Yii::$app->view->params['meta_title'] = '管理员列表';
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
开发者ID:wordnews,项目名称:wei_shop,代码行数:14,代码来源:UserController.php

示例9: search

 public function search($params)
 {
     $query = User::find();
     $query->joinWith('authAssignment');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'username', $this->content])->andFilterWhere(['like', 'email', $this->status])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'created_at', $this->created_at])->andFilterWhere(['like', 'updated_at', $this->updated_at])->andFilterWhere(['like', 'authAssignment.item_name', $this->item_name]);
     return $dataProvider;
 }
开发者ID:mahmoodkhoeini,项目名称:yii2cms,代码行数:11,代码来源: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]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'role' => $this->role, 'status' => $this->status, 'truename' => $this->truename, 'realcard' => $this->realcard, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'username', $this->truename])->andFilterWhere(['like', 'username', $this->realcard])->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(['>', 'created_at', strtotime($this->created_at)]);
     return $dataProvider;
 }
开发者ID:wuwenhan,项目名称:huoqiwang,代码行数:18,代码来源:UserSearch.php

示例11: actionLogin

 public function actionLogin()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $username = Yii::$app->request->post('login');
     $password = Yii::$app->request->post('password');
     $model = User::find()->where(['username' => Yii::$app->request->post('login')])->one();
     if (!$model) {
         return ['status' => 'error', 'error' => array('login' => 'User with login ' . $username . ' is not registered.')];
     } elseif (!Yii::$app->security->validatePassword($password, $model->password_hash)) {
         return ['status' => 'error', 'error' => array('password' => 'Password incorrect.')];
     } else {
         return ['status' => 'success', 'data' => $model];
     }
 }
开发者ID:Vlad9330,项目名称:waiver,代码行数:14,代码来源:ApiController.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]);
     $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, 'create_time' => $this->create_time]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'pwd', $this->pwd]);
     return $dataProvider;
 }
开发者ID:jia253,项目名称:centosYii2,代码行数:21,代码来源:Users.php

示例13: 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]]]);
     $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, 'dob' => $this->dob, 'gender' => $this->gender]);
     $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', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'image_path', $this->image_path]);
     return $dataProvider;
 }
开发者ID:quyettvq,项目名称:luspel,代码行数:21,代码来源:UserSearch.php

示例14: onSwitch

 public function onSwitch()
 {
     $id = post('user_id');
     $name = post('col');
     $value = !post($name);
     $profile = ProfileModel::where('user_id', $id)->get();
     //ensure that user always has a profile
     if (!$profile) {
         ProfileModel::getFromUser(UserModel::find($id));
         $profile = ProfileModel::where('user_id', $id)->get();
     }
     ProfileModel::where('user_id', $id)->update([$name => $value]);
     return ['value' => $value];
 }
开发者ID:xNok,项目名称:membership,代码行数:14,代码来源:MembershipChecker.php

示例15: 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', 'fullname', $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]);
     return $dataProvider;
 }
开发者ID:Griff19,项目名称:altbur,代码行数:21,代码来源:UserSearch.php


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