当前位置: 首页>>代码示例>>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;未经允许,请勿转载。