當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::query方法代碼示例

本文整理匯總了PHP中app\models\User::query方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::query方法的具體用法?PHP User::query怎麽用?PHP User::query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\User的用法示例。


在下文中一共展示了User::query方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: up

 public function up()
 {
     $rows = User::query(['not', ['email' => null]])->select('id,email')->all();
     foreach ($rows as $row) {
         $this->execute('update gs_users set `email`=\'' . strtolower($row['email']) . '\' where id=' . $row['id']);
     }
 }
開發者ID:Makeyko,項目名稱:galaxysss,代碼行數:7,代碼來源:m150710_112118_users.php

示例2: actionMail

 /**
  * AJAX
  * Создает подписку для авторизованного или неавторизованного пользователя
  * Высылает письмо подтверждения email
  *
  * @return string json
  *                error
  *                101, 'Такая почта уже зарегистрирована'
  */
 public function actionMail()
 {
     $email = self::getParam('email');
     $name = self::getParam('name');
     $email = strtolower($email);
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         return self::jsonErrorId(101, 'Не корректная почта');
     }
     if (User::query(['email' => $email])->exists()) {
         return self::jsonErrorId(101, 'Такая почта уже зарегистрирована');
     }
     if (Yii::$app->user->isGuest) {
         $fields = ['email' => $email, 'datetime_reg' => gmdate('YmdHis'), 'is_active' => 0, 'is_confirm' => 0, 'name_first' => $name];
         foreach (Subscribe::$userFieldList as $field) {
             $fields[$field] = 1;
         }
         $user = User::insert($fields);
     } else {
         /** @var \app\models\User $user */
         $user = Yii::$app->user->identity;
         $fields = ['email' => $email, 'datetime_reg' => gmdate('YmdHis'), 'is_active' => 0, 'is_confirm' => 0];
         foreach (Subscribe::$userFieldList as $field) {
             $fields[$field] = 1;
         }
         $user->update($fields);
     }
     $fields = RegistrationDispatcher::add($user->getId());
     \cs\Application::mail($email, 'Подтверждение почты', 'subscribe_activate', ['url' => Url::to(['subscribe/activate', 'code' => $fields['code']], true), 'user' => $user, 'datetime' => \Yii::$app->formatter->asDatetime($fields['date_finish'])]);
     return self::jsonSuccess();
 }
開發者ID:Makeyko,項目名稱:galaxysss,代碼行數:39,代碼來源:SubscribeController.php

示例3: add

 /**
  * Добавляет записи для рассылки в таблицу рассылки
  *
  * @param SiteContentInterface | \app\models\SubscribeItem $item тема письма
  */
 public static function add($item)
 {
     if ($item instanceof SiteContentInterface) {
         $subscribeItem = $item->getMailContent();
     } else {
         $subscribeItem = $item;
     }
     switch ($subscribeItem->type) {
         case self::TYPE_NEWS:
             $where = ['subscribe_is_news' => 1];
             break;
         case self::TYPE_SITE_UPDATE:
             $where = ['subscribe_is_site_update' => 1];
             break;
         case self::TYPE_MANUAL:
             $where = ['subscribe_is_tesla' => 1];
             //                $where = ['subscribe_is_test' => 1];
             break;
     }
     $emailList = User::query($where)->select('email')->andWhere(['not', ['email' => null]])->andWhere(['not', ['email' => '']])->andWhere(['is_active' => 1])->column();
     //        VarDumper::dump(count($emailList),3,false);exit;
     $rows = [];
     foreach ($emailList as $email) {
         $urlUnSubscribe = Url::to(['subscribe/unsubscribe', 'mail' => $email, 'type' => $subscribeItem->type, 'hash' => self::hashGenerate($email, $subscribeItem->type)], true);
         SubscribeMailItem::insert(['text' => str_replace('{linkUnsubscribe}', $urlUnSubscribe, $subscribeItem->text), 'html' => str_replace('{linkUnsubscribe}', $urlUnSubscribe, $subscribeItem->html), 'subject' => $subscribeItem->subject, 'mail' => $email, 'date_insert' => time()]);
         $rows[] = $email;
     }
     \Yii::info($rows, 'tg\\subscribe');
 }
開發者ID:dram1008,項目名稱:bogdan,代碼行數:34,代碼來源:Subscribe.php

示例4: add

 /**
  * Добавляет записи для рассылки в таблицу рассылки
  *
  * @param SiteContentInterface | \app\models\SubscribeItem $item тема письма
  */
 public static function add($item)
 {
     if ($item instanceof SiteContentInterface) {
         $subscribeItem = $item->getMailContent();
     } else {
         $subscribeItem = $item;
     }
     switch ($subscribeItem->type) {
         case self::TYPE_NEWS:
             $where = ['subscribe_is_news' => 1];
             break;
         case self::TYPE_SITE_UPDATE:
             $where = ['subscribe_is_site_update' => 1];
             break;
         case self::TYPE_MANUAL:
             $where = ['subscribe_is_manual' => 1];
             break;
     }
     $emailList = User::query($where)->select('email')->andWhere(['not', ['email' => null]])->andWhere(['is_active' => 1, 'is_confirm' => 1])->column();
     $rows = [];
     foreach ($emailList as $email) {
         $urlUnSubscribe = Url::to(['subscribe/unsubscribe', 'mail' => $email, 'type' => $subscribeItem->type, 'hash' => self::hashGenerate($email, $subscribeItem->type)], true);
         $rows[] = [str_replace('{linkUnsubscribe}', $urlUnSubscribe, $subscribeItem->text), str_replace('{linkUnsubscribe}', $urlUnSubscribe, $subscribeItem->html), $subscribeItem->subject, $email, time()];
     }
     \Yii::info(ArrayHelper::getColumn($rows, 3), 'gs\\subscribe');
     if (count($rows) > 0) {
         SubscribeMailItem::batchInsert(['text', 'html', 'subject', 'mail', 'date_insert'], $rows);
     }
 }
開發者ID:CAPITALOV,項目名稱:capitalov,代碼行數:34,代碼來源:Subscribe.php

示例5: verify

 public function verify($username, $login_token)
 {
     $user = User::query()->where(['username' => $user_name])->first(['id', 'login_token']);
     if ($user->login_token === $login_token) {
         return $user->id;
     }
     return false;
 }
開發者ID:bitqiu,項目名稱:sweep-api,代碼行數:8,代碼來源:LoginTokenVerifier.php

示例6: up

 public function up()
 {
     $this->execute('ALTER TABLE galaxysss_4.cap_users ADD referal_link VARCHAR(20) NULL;');
     $rows = \app\models\User::query()->select('id')->column();
     foreach ($rows as $id) {
         (new \yii\db\Query())->createCommand()->update('cap_users', ['referal_link' => \cs\services\Security::generateRandomString(20)], ['id' => $id])->execute();
     }
 }
開發者ID:CAPITALOV,項目名稱:capitalov,代碼行數:8,代碼來源:m150905_014130_referal.php

示例7: show

 public function show(UserAuth $user, $id)
 {
     $query = \App\Models\User::query();
     if ($user != null && $user['id'] == $id) {
         $query->select('id', 'username', 'first_name', 'last_name', 'email', 'phone');
     } else {
         $query->select(['id', 'username', 'first_name', 'last_name']);
     }
     return $query->find($id) ?: $this->notFoundJson();
 }
開發者ID:sebalb,項目名稱:shopapp,代碼行數:10,代碼來源:User.php

示例8: validateEmail

 public function validateEmail($attribute, $params)
 {
     if (!User::query(['email' => $this->email])->exists()) {
         $this->addError($attribute, 'Такой пользователь не найден');
     }
     if (!User::query(['email' => $this->email, 'is_confirm' => 1])->exists()) {
         $this->addError($attribute, 'Пользователь еще не подтвердил свой email');
     }
     if (!User::query(['email' => $this->email, 'is_active' => 1])->exists()) {
         $this->addError($attribute, 'Пользователь заблокирован');
     }
 }
開發者ID:dram1008,項目名稱:bogdan,代碼行數:12,代碼來源:PasswordRecover.php

示例9: index

 public function index()
 {
     $users = User::query()->orderBy('name', 'ASC')->get();
     $movies = Movie::query()->orderBy('title', 'ASC')->get();
     $prediction = new Prediction();
     $predictionData = [];
     $users->each(function ($user, $index) use($prediction, &$predictionData) {
         $rateData = ["predictions" => $prediction->make($user), "ratedMovies" => $prediction->getRatedmovies()];
         $predictionData[$user->id] = $rateData;
     });
     $data = ["users" => $users, "movies" => $movies, "predictionData" => $predictionData];
     return view('prediction', $data);
 }
開發者ID:Vandrs,項目名稱:topicos-avancados,代碼行數:13,代碼來源:PredictionController.php

示例10: postLogin

 /**
  * Login process
  */
 public function postLogin()
 {
     //Form not valid
     $validator = true;
     //Error messages
     $data['login_error_messages'] = [];
     //Username
     if (!isset($_POST['username']) || $_POST['username'] == '') {
         //Set error message for login form username
         $data['login_error_messages']['username'] = 'Username is required!';
         //Validator is false
         $validator = false;
     }
     if (!isset($_POST['password']) || $_POST['password'] == '') {
         //Set error message for login form username
         $data['login_error_messages']['password'] = 'Password is required!';
         //Validator is false
         $validator = false;
     }
     //If form is valid the continue processing
     if ($validator) {
         //Query to check username and password in database
         //Create new haser object
         $hasher = new Hash();
         //Get credentials
         $username = $_POST['username'];
         $password = $hasher->make($_POST['password']);
         //Create user model
         $user = new User();
         //Check username an password in database
         $results = $user->query("SELECT * FROM users WHERE username = '" . $username . "' AND password = '" . $password . "'");
         //Login is correct
         if ($results !== false) {
             //Login success
             //Set the sessions data
             $_SESSION['isLoggedIn'] = true;
             $_SESSION['user_id'] = $results[0]['id'];
             //Go back to home page
             header('location:/blog');
         } else {
             //Login incorrect
             $data['alert_login'] = 'Username or password is incorrect';
             //Reload page
             view('login-register', $data);
         }
     } else {
         //Form is not valid
         view('login-register', $data);
     }
 }
開發者ID:AshniSukhoo,項目名稱:blog,代碼行數:53,代碼來源:AuthController.php

示例11: search

 public function search($input)
 {
     $query = User::query();
     $columns = Schema::getColumnListing('users');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
開發者ID:pedro-santiago,項目名稱:decoracasa,代碼行數:15,代碼來源:UserRepository.php

示例12: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $benchmarck = new Benchmark();
     $benchmarck->start();
     $qtdCriar = $this->argument('qtd');
     if (!is_numeric($qtdCriar)) {
         $this->error('Parametro qtd deve ser um numero inteiro.');
         return;
     }
     $qtdUsers = User::query()->count();
     $until = $qtdUsers + $qtdCriar;
     for ($qtdUsers; $qtdUsers < $until; $qtdUsers++) {
         User::create(['name' => 'Usuário ' . ($qtdUsers + 1)]);
     }
     $this->info("Usuarios criados com sucesso!");
     $this->info("Tem decorrido: " . $benchmarck->stop()->elapsedSeconds());
 }
開發者ID:Vandrs,項目名稱:topicos-avancados,代碼行數:22,代碼來源:CreateMultipleUsers.php

示例13: up

 public function up()
 {
     foreach (\app\models\User::query(['referal_code' => null])->select('id')->column() as $id) {
         $this->update(\app\models\User::TABLE, ['referal_code' => \cs\services\Security::generateRandomString(20)], ['id' => $id]);
     }
 }
開發者ID:Makeyko,項目名稱:galaxysss,代碼行數:6,代碼來源:m151006_005217_users.php

示例14: runAction

 /**
  * @return Response
  */
 public function runAction()
 {
     /** @var Criteria $query */
     $query = User::query();
     return $this->response($query);
 }
開發者ID:alevikzs,項目名稱:phrest-app,代碼行數:9,代碼來源:CollectionController.php

示例15: actionStatistic

 public function actionStatistic()
 {
     $data = User::query()->select(['datetime_reg'])->column();
     $data2 = \app\services\Statistic::getIncrementDataAllGraphic($data, 'Y-m-d');
     $new = [];
     for ($i = 0; $i < count($data2['x']); $i++) {
         if ($data2['x'][$i] > '2015-07-18') {
             $new['x'][] = (new \DateTime($data2['x'][$i]))->format('d.m');
             $new['y'][] = $data2['y'][$i];
         }
     }
     $data2 = $new;
     $data3 = GraphExporter::convert(['rows' => [User::query()->select(['COUNT(id) as `kurs`', 'DATE(datetime_reg) as `date`'])->groupBy('DATE(datetime_reg)')->all()], 'formatX' => 'd.m', 'start' => new \DateTime('2015-07-05'), 'isExcludeWeekend' => false]);
     return $this->render(['lineArray' => $data3, 'lineArray2' => ['x' => $data2['x'], 'y' => [$data2['y']]]]);
 }
開發者ID:Makeyko,項目名稱:galaxysss,代碼行數:15,代碼來源:SiteController.php


注:本文中的app\models\User::query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。