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


PHP Facilities::model方法代碼示例

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


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

示例1: actionIndex

 public function actionIndex()
 {
     $model = Facilities::model()->find();
     $flag = 0;
     $flag1 = 0;
     $flag2 = 0;
     if (!empty($_POST['Facilities'])) {
         $image1_old = $model->attributes['image1'];
         if (!empty(CUploadedFile::getInstance($model, 'image1')->name)) {
             $image1_old = $model->attributes['image1'];
             $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image1_old);
             if (file_exists($path) && !empty($image1_old)) {
                 unlink($path);
             }
             $model->attributes = $_POST['Facilities'];
             $model->image1 = CUploadedFile::getInstance($model, 'image1');
             $image = $model->image1;
             $imageType = explode('.', $model->image1->name);
             $imageType = $imageType[count($imageType) - 1];
             $imageName = md5(uniqid()) . '.' . $imageType;
             $model->image1 = $imageName;
             $images_path = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName;
             $flag = 1;
         } else {
             $model->image1 = $image1_old;
             $model->attributes = $_POST['Facilities'];
         }
         $image2_old = $model->attributes['image2'];
         if (!empty(CUploadedFile::getInstance($model, 'image2')->name)) {
             $image2_old = $model->attributes['image2'];
             $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image2_old);
             if (file_exists($path) && !empty($image2_old)) {
                 unlink($path);
             }
             $model->attributes = $_POST['Facilities'];
             $model->image2 = CUploadedFile::getInstance($model, 'image2');
             $image1 = $model->image2;
             $imageType = explode('.', $model->image2->name);
             $imageType = $imageType[count($imageType) - 1];
             $imageName = md5(uniqid()) . '.' . $imageType;
             $model->image2 = $imageName;
             $images_path1 = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName;
             $flag1 = 1;
         } else {
             $model->attributes = $_POST['Facilities'];
             $model->image2 = $image2_old;
         }
         $image3_old = $model->attributes['image3'];
         if (!empty(CUploadedFile::getInstance($model, 'image3')->name)) {
             $image3_old = $model->attributes['image3'];
             $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image3_old);
             if (file_exists($path) && !empty($image3_old)) {
                 unlink($path);
             }
             $model->image3 = CUploadedFile::getInstance($model, 'image3');
             $image2 = $model->image3;
             $imageType = explode('.', $model->image3->name);
             $imageType = $imageType[count($imageType) - 1];
             $imageName = md5(uniqid()) . '.' . $imageType;
             $model->image3 = $imageName;
             $images_path2 = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName;
             $flag2 = 1;
         } else {
             $model->image3 = $image3_old;
         }
         if ($model->save()) {
             Yii::app()->user->setFlash('success', translate('Cập nhật thành công.'));
             if ($flag == 1) {
                 $image->saveAs($images_path);
             }
             if ($flag1 == 1) {
                 $image1->saveAs($images_path1);
             }
             if ($flag2 == 1) {
                 $image2->saveAs($images_path2);
             }
             $this->redirect(PIUrl::createUrl('/admin/facilities'));
         }
     }
     $this->render('index', array('model' => $model));
 }
開發者ID:phiphi1992,項目名稱:fpthue,代碼行數:81,代碼來源:FacilitiesController.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 the ID of the model to be loaded
  */
 public function loadModel($type, $id)
 {
     if ($type == 'Employees') {
         $model = Employees::model()->findByPk($id);
     } elseif ($type == 'Hardware') {
         $model = Hardware::model()->findByPk($id);
     } elseif ($type == 'Facilities') {
         $model = Facilities::model()->findByPk($id);
     } elseif ($type == 'CustomResources') {
         $model = CustomResources::model()->findByPk($id);
     }
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
開發者ID:rknox,項目名稱:PPM-App,代碼行數:21,代碼來源:ResourcesController.php


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