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


PHP Users::findOne方法代码示例

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


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

示例1: sendMailToAuthor

 public function sendMailToAuthor($news, $subject)
 {
     $user = \app\models\Users::findOne($news->user_id);
     $body = sprintf('%s <br />
         Ссылка на новость - %s', $subject['author'], $this->urlToNews($news->id));
     $this->sendMail($user->email, $subject['author'], $body);
 }
开发者ID:igribov,项目名称:question-list,代码行数:7,代码来源:Mail.php

示例2: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param null $user_id
  * @param null $group_id
  * @throws \yii\web\NotFoundHttpException
  * @return ActiveDataProvider
  */
 public function search($user_id = null, $group_id = null)
 {
     $query = Beacons::find();
     if (!Yii::$app->user->can(RbacController::admin)) {
         $user = Users::getLogged(true);
         $user->getBeaconsQuery($query);
     }
     if ($user_id !== null) {
         $user = Users::findOne(['id' => $user_id]);
         $user->getBeaconsQuery($query);
     }
     if ($group_id !== null) {
         $group = Groups::findOne(['id' => $group_id]);
         $query = $group->getBeacons();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     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, 'minor' => $this->minor, 'major' => $this->major]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'uuid', $this->uuid]);
     return $dataProvider;
 }
开发者ID:DezMonT765,项目名称:beacon-cms,代码行数:33,代码来源:BeaconsSearch.php

示例3: actionAjax

 public function actionAjax()
 {
     $resultArray = array(2 => 0, 131 => 0, 25 => 0);
     $words = (new \yii\db\Query())->select(['translateWord', 'wordTranslate', 'typeWord', 'flashCards'])->from('users')->where(['userId' => $this->userId])->one();
     foreach ($resultArray as $key => $value) {
         if (strpos($words['flashCards'], "|{$key}|")) {
             $words['flashCards'] = str_replace("|{$key}|", "|", $words['flashCards']);
         }
     }
     $wordsModel = Users::findOne($this->userId);
     $wordsModel->flashCards = $words['flashCards'];
     if ($wordsModel->update()) {
         echo 'ok';
     } else {
         echo 'no';
     }
     //        if (Yii::$app->request->isAjax) {
     //            $success = true;
     //            foreach ($_POST['ajaxData'] as $key => $value) {
     //                $words = Vocabulary::findOne($key);
     //                if (!$words->updateCounters(['Learned' => $value])){
     //                    $success = false;
     //                }
     //            }
     //            if (!$success){
     //                echo  'Your session progress has successfully been saved';
     //            }else echo 'Your session progress has not been saved! An error has occured during proccessing';
     //        }
 }
开发者ID:volodymyr-nechai,项目名称:notozza,代码行数:29,代码来源:ExerciseController.php

示例4: actionCreate

 /**
  * Creates a new Exchange model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Exchange();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->beforeValidate()) {
             if ($model->selectorIncomeExpenses == 'income') {
                 $model->expenses = 0;
                 $model->income = $model->inputIncomeExpenses;
             } else {
                 $model->income = 0;
                 $model->expenses = $model->inputIncomeExpenses;
             }
             if ($model->create_time) {
                 false;
             } else {
                 $model->create_time = date('Y-m-d');
             }
         }
         $users = Users::findOne(Yii::$app->user->id);
         $location = $users->location_id;
         $model_report = $model->updateReport($location, $model->create_time, $model->currency, $model->income, $model->expenses, $model->transaction, $model->bo);
         $model->location_id = $location;
         $model->save();
         $model_report->save();
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
开发者ID:ap-404,项目名称:rate,代码行数:34,代码来源:ExchangeController.php

示例5: execute

 public function execute($user, $item, $params)
 {
     $user_role = Users::findOne($user)->authAssignments->item_name;
     if (isset($params['news'])) {
         $news_status = $params['news']->status;
         $news_category = $params['news']->category_id;
         $relCat = !is_null(RelationCategories::findOne(['user_id' => $user, 'category_id' => $news_category]));
         if ($user_role == 'moderator' && $relCat && isset($params['action']) && $params['action'] == 'view') {
             return true;
         }
         if ($news_status == News::MODER_NEWS) {
             if ($user_role == 'moderator') {
                 return $relCat;
             }
         }
         if ($news_status == News::SMODER_NEWS) {
             if ($user_role == 'super_moderator') {
                 return true;
             }
         }
     } elseif (isset($params['question'])) {
         if ($user_role == 'moderator') {
             $news = News::findOne($params['question']->news_id);
             if (!is_null($news)) {
                 if ($news->status == News::MODER_NEWS && !is_null(RelationCategories::findOne(['user_id' => $user, 'category_id' => $news->category_id]))) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:igribov,项目名称:question-list,代码行数:32,代码来源:StatusAllowUpdateRule.php

示例6: actionConfirm

 public function actionConfirm()
 {
     $table = new Users();
     if (Yii::$app->request->get()) {
         //Obtenemos el valor de los parámetros get
         $id = Html::encode($_GET["id"]);
         $authKey = $_GET["authKey"];
         if ((int) $id) {
             //Realizamos la consulta para obtener el registro
             $model = $table->find()->where("id=:id", [":id" => $id])->andWhere("authKey=:authKey", [":authKey" => $authKey]);
             //Si el registro existe
             if ($model->count() == 1) {
                 $activar = Users::findOne($id);
                 $activar->activate = 1;
                 if ($activar->update()) {
                     echo "Enhorabuena registro llevado a cabo correctamente, redireccionando ...";
                     echo "<meta http-equiv='refresh' content='8; " . Url::toRoute("site/login") . "'>";
                 } else {
                     echo "Ha ocurrido un error al realizar el registro, redireccionando ...";
                     echo "<meta http-equiv='refresh' content='8; " . Url::toRoute("site/login") . "'>";
                 }
             } else {
                 //Si no existe redireccionamos a login
                 return $this->redirect(["site/login"]);
             }
         } else {
             //Si id no es un número entero redireccionamos a login
             return $this->redirect(["site/login"]);
         }
     }
 }
开发者ID:lucho314,项目名称:cae,代码行数:31,代码来源:SiteController.php

示例7: findModel

 /**
  * Finds the Users model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Users the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Users::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:ap-404,项目名称:rate,代码行数:15,代码来源:UsersController.php

示例8: findByUsername

 static function findByUsername($username)
 {
     $user = Users::findOne(['username' => $username]);
     if ($user) {
         return new static($user);
     }
     return null;
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:8,代码来源:User.php

示例9: findModel

 public function findModel($id)
 {
     if (($model = Users::findOne($id)) != null) {
         return $model;
     } else {
         throw new NotFoundHttpException('gak iso bos, ojo dipekso');
     }
 }
开发者ID:Mboreinz,项目名称:projek-yii2,代码行数:8,代码来源:UsersController.php

示例10: findIdentity

 public static function findIdentity($id)
 {
     try {
         $user = Users::findOne($id);
         return $user ? new static($user) : false;
     } catch (Exception $e) {
         return false;
     }
 }
开发者ID:bth2008,项目名称:rferu,代码行数:9,代码来源:User.php

示例11: 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 integer $id
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Users::findOne($id)) !== null) {
         return $model;
     } else {
         $this->getHeader(400);
         echo json_encode(['status' => 0, 'error_code' => 400, 'message' => 'Bad request'], JSON_PRETTY_PRINT);
         exit;
         // throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:huangsen0912,项目名称:yii2-rest-api-Basic-Application-Template-,代码行数:19,代码来源:UserController.php

示例12: login

 /**
  * Logs in a user using the provided username and password.
  * @return boolean whether the user is logged in successfully
  */
 public function login()
 {
     if ($this->validate()) {
         $model = Users::findOne(['mail' => $this->username]);
         $model->ip = \Yii::$app->getRequest()->getUserIP();
         $model->agent = \Yii::$app->getRequest()->getUserAgent();
         $model->last_login = new yii\db\Expression("NOW()");
         $model->save();
         return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
     }
     return false;
 }
开发者ID:pumi11,项目名称:aau,代码行数:16,代码来源:LoginForm.php

示例13: actionView

 public function actionView($link)
 {
     /** @var Users $user */
     $user = Users::findOne(['link' => $link]);
     if (!$user) {
         throw new NotFoundHttpException('Неверная ссылка или проект удален');
     }
     Yii::$app->session->set('user', $user);
     $project = $user->project;
     $photos = $user->photos;
     return $this->render('view', ['user' => $user, 'project' => $project, 'photos' => $photos]);
 }
开发者ID:CyanoFresh,项目名称:SelectPhoto,代码行数:12,代码来源:LinkController.php

示例14: createClassInfo

 public function createClassInfo($model)
 {
     // 获取专业的中文名
     $majorid = substr($model->st_class, 0, 4);
     $major = Major::findOne($majorid);
     $model->class_major = $major->mj_name_zh;
     // 获取专业级数
     $model->class_year = '20' . substr($model->st_class, 4, 2) . '级';
     // 获取辅导员姓名
     $user = Users::findOne($model->teID);
     $model->te_name = $user->te_name;
     return $model;
 }
开发者ID:PichurChill,项目名称:sues_print,代码行数:13,代码来源:teClass.php

示例15: actionMyWishlist

 public function actionMyWishlist()
 {
     try {
         $id = Yii::$app->session['user_id'];
         if (empty($id)) {
             $this->redirect('http://bluebee-uet.com');
         }
         $data = Documents::getDocumentsByWishlist($id);
         $user = Users::findOne(['id' => $id]);
         Yii::$app->view->title = $user->name . ', đây là tài liệu bạn đã đánh dấu';
         return $this->render('//document/documents', $data);
     } catch (Exception $ex) {
     }
 }
开发者ID:huynt57,项目名称:bluebee-ng,代码行数:14,代码来源:UserController.php


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