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


PHP PageType::model方法代码示例

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


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

示例1: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $page_type_list = array();
     $type = PageType::model()->findAll('status=1');
     foreach ($type as $page_type) {
         $page_type_list[$page_type->page_type_id] = $page_type->name_th;
     }
     $page_id_list = array();
     $page = Page::model()->findAll('status=1');
     foreach ($page as $page_list) {
         $page_id_list[$page_list->page_id] = $page_list->name_th;
     }
     if (isset($_POST['LeftMenu'])) {
         $_POST['LeftMenu']['user_id'] = Yii::app()->user->id;
         $model->attributes = $_POST['LeftMenu'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model, 'page_type_list' => $page_type_list, 'page_id_list' => $page_id_list));
 }
开发者ID:ultr4h4ck,项目名称:project_gspa,代码行数:29,代码来源:LeftMenuController.php

示例2: 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 PageType the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = PageType::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:ultr4h4ck,项目名称:project_gspa,代码行数:15,代码来源:PageTypeController.php

示例3: actionUpdate

 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $page_type_list = array();
     $type = PageType::model()->findAll('status=1');
     foreach ($type as $page_type) {
         $page_type_list[$page_type->page_type_id] = $page_type->name_th;
     }
     if (isset($_POST['Page'])) {
         $record_file_en = $model->pdf_en;
         $record_file_th = $model->pdf_th;
         $record_image = $model->images;
         $record_thumb = $model->thumbnail;
         $_POST['Page']['user_id'] = Yii::app()->user->id;
         list($day, $month, $year) = explode('/', $_POST['Page']['create_date']);
         $create_date = $year . '-' . $month . '-' . $day;
         $_POST['Page']['create_date'] = $create_date;
         $model->attributes = $_POST['Page'];
         $file_en = CUploadedFile::getInstance($model, 'pdf_en');
         if ($file_en) {
             $genName = 'en_pdf_' . date('YmdHis');
             $saveName = $genName;
             while (file_exists($this->upload_path . $saveName . '.' . $file_en->getExtensionName())) {
                 $saveName = $genName . '-' . rand(0, 99);
             }
             $model->pdf_en = $saveName . '.' . $file_en->getExtensionName();
         }
         $file_th = CUploadedFile::getInstance($model, 'pdf_th');
         if ($file_th) {
             $genName = 'th_pdf_' . date('YmdHis');
             $saveName = $genName;
             while (file_exists($this->upload_path . $saveName . '.' . $file_th->getExtensionName())) {
                 $saveName = $genName . '-' . rand(0, 99);
             }
             $model->pdf_th = $saveName . '.' . $file_th->getExtensionName();
         }
         $images = CUploadedFile::getInstance($model, 'images');
         if ($images) {
             $genName = 'img_' . date('YmdHis');
             $saveName = $genName;
             while (file_exists($this->upload_path_images . $saveName . '.' . $images->getExtensionName())) {
                 $saveName = $genName . '-' . rand(0, 99);
             }
             $model->images = $saveName . '.' . $images->getExtensionName();
         }
         $thumbnail = CUploadedFile::getInstance($model, 'thumbnail');
         if ($thumbnail) {
             $genName = 'thumb_' . date('YmdHis');
             $saveName = $genName;
             while (file_exists($this->upload_path_thumb . $saveName . '.' . $thumbnail->getExtensionName())) {
                 $saveName = $genName . '-' . rand(0, 99);
             }
             $model->thumbnail = $saveName . '.' . $thumbnail->getExtensionName();
         }
         if ($model->save()) {
             if ($file_en) {
                 if (file_exists($this->upload_path . $record_file_en)) {
                     @unlink($this->upload_path . $record_file_en);
                 }
                 $file_en->saveAs($this->upload_path . $model->pdf_en);
             }
             if ($file_th) {
                 if (file_exists($this->upload_path . $record_file_th)) {
                     @unlink($this->upload_path . $record_file_th);
                 }
                 $file_th->saveAs($this->upload_path . $model->pdf_th);
             }
             if ($images) {
                 if (file_exists($this->upload_path_images . $record_image)) {
                     @unlink($this->upload_path_images . $record_image);
                 }
                 $images->saveAs($this->upload_path_images . $model->images);
             }
             if ($thumbnail) {
                 if (file_exists($this->upload_path_thumb . $record_thumb)) {
                     @unlink($this->upload_path_thumb . $record_thumb);
                 }
                 $thumbnail->saveAs($this->upload_path_thumb . $model->thumbnail);
             }
             $this->redirect(array('index'));
         }
     }
     $this->render('update', array('model' => $model, 'page_type_list' => $page_type_list));
 }
开发者ID:ultr4h4ck,项目名称:project_gspa,代码行数:91,代码来源:PageController.php


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