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


PHP Users::findByEmail方法代码示例

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


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

示例1: getUser

 /**
  * Finds user by [[username]]
  *
  * @return Users|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = Users::findByEmail($this->email);
     }
     return $this->_user;
 }
开发者ID:DezMonT765,项目名称:beacon-cms,代码行数:12,代码来源:LoginForm.php

示例2: getUser

 /**
  * Finds user by [[email]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = Users::findByEmail($this->email);
         if (!$this->_user || !$this->_user->getAttribute('user_mail_valid')) {
             return false;
         }
         //            $this->_user = User::findByUsername($this->username);
     }
     return $this->_user;
 }
开发者ID:ubasma,项目名称:demo,代码行数:16,代码来源:LoginForm.php

示例3: sendMoney

 /**
  * Отправка денег между пользователями
  * @param $email
  * @param $money
  * @throws \yii\db\Exception
  */
 public static function sendMoney($email, $money)
 {
     $userTo = Users::findByEmail($email);
     $userFrom = Users::findOne(\Yii::$app->user->id);
     $money = (int) ($money * 100) / 100;
     $transaction = \Yii::$app->db->beginTransaction();
     try {
         if ($money <= 0) {
             throw new Exception(" Money < 0");
         }
         if ($userTo && $userTo->user_id != $userFrom->user_id) {
             $userMoney = \Yii::$app->db->createCommand("SELECT user_id, user_money FROM public.user WHERE user_id IN (:idFrom, :idTo) FOR UPDATE", array(':idTo' => $userTo->user_id, ':idFrom' => $userFrom->user_id))->queryAll();
             if ($userMoney[0]['user_id'] == $userTo->user_id) {
                 $userMoneyTo = $userMoney[0]['user_money'];
                 $userMoneyFrom = $userMoney[1]['user_money'];
             } else {
                 $userMoneyTo = $userMoney[1]['user_money'];
                 $userMoneyFrom = $userMoney[0]['user_money'];
             }
             if ($userMoneyFrom - $money < 0) {
                 throw new Exception(" User (id: " . $userFrom->user_id . ") not enough money");
             }
             $to_balance = $userMoneyTo + $money;
             $userTo->user_money = $to_balance;
             $from_balance = $userMoneyFrom - $money;
             $userFrom->user_money = $from_balance;
             if ($userTo->save() && $userFrom->save()) {
                 self::setOperation($userFrom->user_id, $userTo->user_id, $money, $to_balance, $from_balance);
                 $transaction->commit();
             } else {
                 throw new Exception(" User (id:" . $userFrom->user_id . ") failed to add money to user (id: " . $userTo->user_id . ")");
             }
         } else {
             throw new Exception(" user (email: " . $email . ") not exist or user (id: " . $userTo->user_id . ") wanted to transfer the money at yourself");
         }
     } catch (Exception $e) {
         $text = date('Y-m-d H:i') . $e->getMessage() . PHP_EOL;
         file_put_contents("demoLog.txt", $text, FILE_APPEND);
         $transaction->rollBack();
     }
 }
开发者ID:ubasma,项目名称:demo,代码行数:47,代码来源:Operation.php

示例4: actionValidemail

 /**
  * Проверяем есть ли почта на которую пользователь отправляет деньги
  * Хватает ли ему на это денег
  */
 public function actionValidemail()
 {
     $email = Yii::$app->request->post('email');
     if (!empty($email)) {
         $userSend = Users::findByEmail($email);
         $money = Users::getUserInf(Yii::$app->user->id);
         $money = $money['user_money'];
         $answer['money'] = $money;
         if (is_null($userSend)) {
             $answer['email'] = 'false';
             echo json_encode($answer);
         } else {
             $answer['email'] = 'true';
             echo json_encode($answer);
         }
         exit;
     }
 }
开发者ID:ubasma,项目名称:demo,代码行数:22,代码来源:SiteController.php


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