當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。