ARGroupon::model PHP Method

model() public static method

审核状态
public static model ( $className = __CLASS__ )
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

Usage Example

コード例 #1
0
 public function actionUpdate($id)
 {
     $model = ARGroupon::model()->findByPk($id);
     if ($model == null) {
         $this->go('该商品不存在', Yii::app()->request->urlReferrer);
     }
     $model->setScenario('sell');
     $this->performAjaxValidation($model);
     if (!empty($_POST['ARGroupon'])) {
         //            dump($_FILES);
         //            dump($_POST);exit;
         $model->attributes = $_POST['ARGroupon'];
         if ($model->validate()) {
             $fileUpload = new FileUpload(array($model, 'image'), 'upload/groupon');
             if (!$fileUpload->isNull()) {
                 $filename = $fileUpload->save();
                 if ($filename) {
                     $model->image = $filename;
                 } else {
                     dump($fileUpload->getErrors());
                     throw new CHttpException(300, '图片上传出错');
                 }
             }
             $model->begin_time = strtotime($model->begin_time);
             $model->end_time = strtotime($model->end_time);
             $model->expire_time = strtotime($model->expire_time);
             if ($model->save()) {
                 Yii::app()->user->setFlash('success', '商品修改成功');
                 //                    $url = $_POST['return_url'];
                 //                    $this->go('商品修改成功', $url, 'success');
             }
         }
     }
     $this->render('update', array('model' => $model));
 }