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


PHP Reg::model方法代碼示例

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


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

示例1: loadModel

 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Reg the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Reg::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
開發者ID:GuraYaroslava,項目名稱:hello-yii,代碼行數:15,代碼來源:RegController.php

示例2: actionBlank

 public function actionBlank($id)
 {
     $event = Event::model()->findByPk($id);
     if (Yii::app()->request->isAjaxRequest) {
         $data = Yii::app()->request->getParam('data');
         $reg = new Reg();
         $reg->user_id = Yii::app()->user->getId();
         $reg->event_id = $event->id;
         try {
             if (!$reg->save()) {
                 throw new CHttpException(500, 'Internal server error.');
             }
             foreach ($data as $key => $value) {
                 $param_value = new ParamValue();
                 $param_value->param_id = $value["id"];
                 $param_value->reg_id = $reg->id;
                 $param_value->value = $value["value"];
                 if (!$param_value->save()) {
                     // @todo Откат всех инсертов.
                     throw new CHttpException(500, 'Internal server error.');
                 }
             }
             echo CJSON::encode(array('code' => 200));
             Yii::app()->end();
         } catch (CDbException $error) {
             throw new CHttpException(400, 'You are already registered for this event.');
         }
     }
     $reg = Reg::model()->findByAttributes(array('user_id' => Yii::app()->user->getId(), 'event_id' => $id));
     if ($reg !== null) {
         $this->redirect(array('user/blank', 'userId' => Yii::app()->user->getId(), 'eventId' => $id));
         Yii::app()->end();
     }
     $this->render('blank', array('event' => $event));
 }
開發者ID:GuraYaroslava,項目名稱:hello-yii,代碼行數:35,代碼來源:SiteController.php


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