当前位置: 首页>>代码示例>>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;未经允许,请勿转载。