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


PHP User::findOne方法代碼示例

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


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

示例1: reminder

 public function reminder($id_user)
 {
     $i = 0;
     if (Zend_Registry::isRegistered('Zend_Translate')) {
         $translator = Zend_Registry::get('Zend_Translate');
     }
     if (!$id_user || $id_user == null) {
         $modelReminder = new Reminder();
         $dataReminders = $modelReminder->fetchToSendEmailAll();
     } elseif ($id_user) {
         $modelReminder = new Reminder();
         $dataReminders = $modelReminder->fetchToSendEmail($id_user);
     }
     foreach ($dataReminders as $dataReminder) {
         $modelUser = new User();
         $dataUsers = $modelUser->findOne($dataReminder['created_by']);
         $userEmail = $dataUser['email'];
         $this->view->description = str_replace("ó", "ó", strip_tags($dataReminder['description']));
         $body = $this->view->render('/_mail/reminder.phtml');
         $client = new Logic_MailerAdapter();
         $client->mail($userEmail, $translator->translate('Reminder') . ' - ' . $dataReminder['title'], array('type' => 1, 'content' => $body));
         $modelReminder->setAsSent($dataReminder['id']);
         $i++;
     }
     return $i;
 }
開發者ID:knatorski,項目名稱:SMS,代碼行數:26,代碼來源:Mailer.php

示例2: findByEmail

 /**
  * @param string $email
  * @return app\models\User|null User
  */
 public static function findByEmail($email)
 {
     $dbUser = User::findOne(['email' => $email]);
     if ($dbUser) {
         return UserIdent::initFromDbInstance($dbUser);
     }
     return null;
 }
開發者ID:alexletsu,項目名稱:kiytes,代碼行數:12,代碼來源:UserIdent.php

示例3: testModel

 public function testModel()
 {
     $this->assertEquals(User::find(1)->email, 'email1@example.com');
     $this->assertEquals(User::first()->email, 'email1@example.com');
     $this->assertEquals(User::last()->email, 'email3@example.com');
     $this->assertEquals(User::count(), 3);
     $this->assertEquals(User::findOne(['email'], ['email1@example.com'])->email, 'email1@example.com');
     $this->assertEquals(User::findOne(['first_name', 'last_name'], ['John', 'Doe'])->email, 'email1@example.com');
     $this->assertCount(3, User::all());
 }
開發者ID:gigorok,項目名稱:php-orm,代碼行數:10,代碼來源:ModelTest.php

示例4: testAction

 protected function testAction()
 {
     $translate = $this->application->getBootstrap()->getResource('translate');
     $view = $this->application->getBootstrap()->getResource('view');
     $view->setScriptPath(APPLICATION_PATH . '/views/scripts');
     $u = new User();
     $u_row = $u->findOne($_SERVER['argv'][6]);
     $mailer = new Logic_Mailer($view, $translate);
     $mailer->userPass('asdf', $u_row);
 }
開發者ID:knatorski,項目名稱:SMS,代碼行數:10,代碼來源:mail_cmd.php

示例5: getList

 public static function getList()
 {
     $time = time();
     $return = [];
     foreach (self::find()->asArray()->all() as $item) {
         $user = User::findOne($item['user_id']);
         if ($user) {
             $inactiveSince = $time - $item['last_timestamp'];
             $return[] = ['firstname' => $user->firstname, 'lastname' => $user->lastname, 'email' => $user->email, 'last_timestamp' => $item['last_timestamp'], 'is_active' => $inactiveSince >= 120 ? false : true, 'inactive_since' => round($inactiveSince / 60) . ' min'];
         }
     }
     return $return;
 }
開發者ID:gitter-badger,項目名稱:luya,代碼行數:13,代碼來源:UserOnline.php

示例6: sendEmail

 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
     if ($user) {
         if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             return \Yii::$app->mailer->compose('passwordResetToken', ['user' => $user])->setFrom([\Yii::$app->cms->adminEmail => \Yii::$app->cms->appName . ' robot'])->setTo($this->email)->setSubject(\Yii::t('app', 'Password reset for ') . \Yii::$app->cms->appName)->send();
         }
     }
     return false;
 }
開發者ID:Liv1020,項目名稱:cms,代碼行數:19,代碼來源:PasswordResetRequestForm.php

示例7: dispatchLoopStartup

 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     if ($identity = Zend_Auth::getInstance()->getIdentity()) {
         $user = new User();
         $id = $identity->id;
         $userRow = $user->findOne($id)->toArray();
         if ($userRow['tmp_password'] === true && ($request->getControllerName() != 'auth' || $request->getActionName() != 'changepassword')) {
             $conv = new Base_Controller_Action_Helper_IdConvert();
             $id = $conv->strToHex($id);
             $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
             $redirector->setGotoSimple('changepassword', 'auth', null, array('id' => $id));
         }
     }
 }
開發者ID:knatorski,項目名稱:SMS,代碼行數:14,代碼來源:TmpPasswordChange.php

示例8: sendEmail

 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
     if ($user) {
         if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             \Yii::$app->mailer->view->theme->pathMap = ArrayHelper::merge(\Yii::$app->mailer->view->theme->pathMap, ['@app/mail' => ['@skeeks/cms/mail-templates']]);
             return \Yii::$app->mailer->compose('@app/mail/password-reset-token', ['user' => $user])->setFrom([\Yii::$app->cms->adminEmail => \Yii::$app->cms->appName . ' robot'])->setTo($this->email)->setSubject(\Yii::t('skeeks/cms', 'Password reset for ') . \Yii::$app->cms->appName)->send();
         }
     }
     return false;
 }
開發者ID:skeeks-cms,項目名稱:cms,代碼行數:20,代碼來源:PasswordResetRequestForm.php

示例9: sendEmail

 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
     if (!$user) {
         return false;
     }
     if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
         $user->generatePasswordResetToken();
     }
     if (!$user->save()) {
         return false;
     }
     return Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Password reset for ' . \Yii::$app->name)->send();
 }
開發者ID:humanized,項目名稱:yii2-user-module,代碼行數:20,代碼來源:PasswordResetRequestForm.php

示例10: updateWsClientaction

 protected function updateWsClientaction()
 {
     $sql = 'SELECT id,login,first_name,surname,email from "user" where ws_client_id is null';
     $model = new User();
     $u = $model->getAdapter()->query($sql);
     $users = $u->fetchAll();
     foreach ($users as $user) {
         $values = array();
         $clientModel = new Wsclient();
         $clientData = array('client_name' => $user['login'], 'pm_name' => $user['first_name'] . ' ' . $user['surname'], 'pm_email' => $user['email'], 'ip_address' => array());
         $newClient = $clientModel->createRow($clientData);
         $values['ws_client_id'] = $newClient->save();
         $row = $model->findOne($user['id']);
         $row->setFromArray($values);
         $row->save();
     }
 }
開發者ID:knatorski,項目名稱:SMS,代碼行數:17,代碼來源:update_user.php

示例11: currentUser

 static function currentUser()
 {
     $cookie = new CookieSigner(Config::app()['BASE_KEY']);
     if (isset($_SESSION['userId']) && ($userId = $_SESSION['userId'])) {
         $user = new User();
         return $user->findOne($userId);
     } else {
         if ($userId = $cookie->get('userId')) {
             $user = new User();
             $user->findOne($userId);
             if ($user && $user->isAuthenticated('remember', $cookie->get('rememberToken'))) {
                 self::logIn($user);
                 return $user;
             }
         }
     }
     return null;
 }
開發者ID:arjayads,項目名稱:php-simple-auth,代碼行數:18,代碼來源:Session.php

示例12: logIn

 private function logIn()
 {
     $success = false;
     if (!empty($_POST['email']) && !empty($_POST['pass'])) {
         $user = User::findOne(['email' => $_POST['email']]);
         if ($_POST['pass'] === $user->pass) {
             $user->token = Text::generateRandomString();
             $user->save();
             setcookie('user_id', $user->id, 0, '/');
             setcookie('token', $user->token, 0, '/');
             $success = true;
         }
     }
     if ($success) {
         return $this->redirect('/admin');
     }
     return $this->redirect('/log-in?error=1');
 }
開發者ID:ArtemRochev,項目名稱:MVC-Framework,代碼行數:18,代碼來源:ControllerLogIn.php

示例13: buildSQl

 protected function buildSQl()
 {
     $select = $this->dbModelTable->select();
     $user = new User();
     if (isset($this->filterdata['deleg_no']) and !empty($this->filterdata['deleg_no'])) {
         $select->where('deleg_no = ?', $this->filterdata['deleg_no']);
     }
     if (isset($this->filterdata['employee']) and !empty($this->filterdata['employee'])) {
         $tetaId = $user->findOne($this->filterdata['employee'])->teta_id;
         $select->where('teta_id = ?', $tetaId);
     } else {
         if (isset($this->filterdata['branch']) and !empty($this->filterdata['branch'])) {
             $userRowset = $user->fetchAll('id_branch = ' . $this->filterdata['branch']);
             $inStmt = array();
             foreach ($userRowset as $row) {
                 $inStmt[] = $row->teta_id;
             }
             $select->where('teta_id IN (?)', $inStmt);
         }
     }
     return $select->__toString();
 }
開發者ID:knatorski,項目名稱:SMS,代碼行數:22,代碼來源:Searcher.php

示例14: testSave

 public function testSave()
 {
     $user = new User();
     $user->name = 'John Doe';
     $this->assertFalse($user->exists);
     $this->assertEquals(0, User::count());
     $this->assertEquals(null, $user->_id);
     $user->save();
     $this->assertTrue($user->exists);
     $this->assertEquals(1, User::count());
     $this->assertEquals('John Doe', $user->name);
     $this->assertInstanceOf('MongoID', $user->_id);
     $test = User::findOne(array('name' => 'John Doe'));
     $this->assertEquals($test, $user);
     // backup id
     $id = $user->_id;
     $user->name = 'Jane Doe';
     $user->save();
     $this->assertEquals('Jane Doe', $user->name);
     $this->assertEquals($id, $user->_id);
     $this->assertNotEquals($test, $user);
 }
開發者ID:dilanWijerathne,項目名稱:laravel-mongodb-lite,代碼行數:22,代碼來源:ModelTest.php

示例15: findIdentityByAccessToken

 public static function findIdentityByAccessToken($token, $type = null)
 {
     return User::findOne(['tocken' => $token]);
 }
開發者ID:MaoCzedun,項目名稱:AdCoin,代碼行數:4,代碼來源:User.php


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