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


PHP Codes::model方法代码示例

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


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

示例1: actionClaim

 public function actionClaim()
 {
     $this->layout = "home";
     $model = new Users();
     //Check if user has entered the email id or not
     if (isset($_POST['email'])) {
         $_SESSION['claimEmailVal'] = $_POST['email'];
         $_SESSION['claimUniqueCodeVal'] = $_POST['unique_code'];
         $user = Users::model()->findByAttributes(array('email' => $_POST['email']));
         $codeVal = Codes::model()->findByAttributes(array('uniquecode' => $_POST['unique_code']));
         if (!$user) {
             Yii::app()->user->setFlash('email', 'Please enter a registered email address');
         } else {
             if (!$codeVal) {
                 Yii::app()->user->setFlash('failmessage', 'Please try your unique code again');
             } elseif ($codeVal->status == 0) {
                 //updating Codes table for status and other values
                 $updateCodes = Yii::app()->db->createCommand()->update('codes', array('status' => 1, 'date_claimed' => date('Y-m-d H:i:s'), 'claimed_by' => $user['id']), 'uniquecode=:uniquecode', array(':uniquecode' => $codeVal->uniquecode));
                 //updating User table for status
                 $updateUsers = Yii::app()->db->createCommand()->update('users', array('status' => 'Claimed'), 'id=:id', array(':id' => $user->id));
                 //for sending email to users who successfully claims
                 $userFname = $user->first_name;
                 $userEmail = $user->email;
                 $message = new YiiMailMessage();
                 //this points to the file claim.php inside the view path
                 $message->view = "claim";
                 $params = array('name' => $userFname);
                 $message->subject = 'Congratulations';
                 $message->setBody($params, 'text/html');
                 $message->addTo($userEmail);
                 $message->from = 'noreply@fifa14fanatics.com.au';
                 Yii::app()->mail->send($message);
                 //for sending email to users who successfully claims ends here
                 session_destroy();
                 session_start();
                 $_SESSION['claimed'] = 'success';
                 $this->redirect(array('success'));
                 //$this->redirect(array('failure'));
             } elseif ($codeVal->status == 1) {
                 session_destroy();
                 session_start();
                 $_SESSION['claimed'] = 'failure';
                 $this->redirect(array('failure'));
             } else {
                 $this->redirect(array('success'));
             }
         }
     }
     $this->render('claim', array('model' => $model));
 }
开发者ID:abhikalotra,项目名称:Samples1,代码行数:50,代码来源:UsersController.php


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