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


PHP Output::save方法代码示例

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


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

示例1: setSave

 protected function setSave($quality = 100)
 {
     $output = new Output($this->actions->output, $this->background, $this->layers);
     $this->save = $output->save($quality);
 }
开发者ID:leotaillard,项目名称:btws2016,代码行数:5,代码来源:Run.php

示例2: importExcelToMysql

 /**
  * Import data from excel template
  * @param type $filePath
  * @param type $fields
  * @param Output $model
  * @param type $startingRow
  */
 public function importExcelToMysql($filePath, $fields = array(), $model = null, $startingRow = 2)
 {
     $objPHPExcel = PHPExcel_IOFactory::load($filePath);
     foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
         //field validation
         $fieldValidate = array();
         $validated = FALSE;
         for ($col = 0; $col < count($fields); ++$col) {
             $val = $worksheet->getCellByColumnAndRow($fields[$col]['col'], 1)->getValue();
             $fieldValidate[$fields[$col]['name']] = $val;
         }
         if ($fieldValidate['satker_code'] == 'Kode Satker' and $fieldValidate['activity_code'] == 'Kode Kegiatan' and $fieldValidate['code'] == 'Kode Output' and $fieldValidate['name'] == 'Uraian Output') {
             $validated = TRUE;
         }
         //end of validation
         if ($validated == TRUE) {
             $highestRow = $worksheet->getHighestRow();
             // e.g. 10
             $isSuccess = FALSE;
             for ($row = $startingRow; $row <= $highestRow; ++$row) {
                 $attributes = array();
                 //Read data
                 for ($col = 0; $col < count($fields); ++$col) {
                     $val = $worksheet->getCellByColumnAndRow($fields[$col]['col'], $row)->getValue();
                     $attributes[$fields[$col]['name']] = $val;
                 }
                 //Eof read data
                 $activitycode = trim($attributes['satker_code'], " \t\n\r\v") . '.' . trim($attributes['activity_code'], " \t\n\r\v");
                 $code = $activitycode . '.' . trim($attributes['code'], " \t\n\r\v");
                 $recorded = Output::model()->find(array('condition' => "code='{$code}'"));
                 if ($attributes['satker_code'] != NULL and $attributes['activity_code'] != NULL and $attributes['code'] != NULL and $attributes['name'] != NULL) {
                     if ($recorded) {
                         //Doing update if data with sae code exist
                         $recorded->attributes = $attributes;
                         $satkerCode = isset($attributes['satker_code']) ? trim($attributes['satker_code'], " \t\n\r\v") : NULL;
                         $activityCode = $activitycode;
                         $outputCode = $code;
                         $recorded->satker_code = $satkerCode;
                         $recorded->activity_code = $satkerCode . '.' . $activityCode;
                         $recorded->code = $satkerCode . '.' . $activityCode . '.' . $outputCode;
                         if ($recorded->update()) {
                             $isSuccess = TRUE;
                         }
                         //Eof update data
                     } else {
                         //Doing create data if no recorded data with same code
                         $model = new Output();
                         $model->attributes = $attributes;
                         $satkerCode = isset($attributes['satker_code']) ? trim($attributes['satker_code'], " \t\n\r\v") : NULL;
                         $activityCode = isset($attributes['activity_code']) ? trim($attributes['activity_code'], " \t\n\r\v") : NULL;
                         $outputCode = isset($attributes['code']) ? trim($attributes['code'], " \t\n\r\v") : NULL;
                         $model->satker_code = $satkerCode;
                         $model->activity_code = $satkerCode . '.' . $activityCode;
                         $model->code = $satkerCode . '.' . $activityCode . '.' . $outputCode;
                         if ($model->save()) {
                             $isSuccess = TRUE;
                         }
                         //                        Eof create data
                     }
                 }
             }
             if ($isSuccess) {
                 unlink($filePath);
                 Yii::app()->user->setFlash('success', "File berhasil diimport ke dalam master");
                 $this->redirect(array('index'));
             } else {
                 unlink($filePath);
                 Yii::app()->user->setFlash('error', "Mohon isikan data secara lengkap");
             }
         } else {
             unlink($filePath);
             Yii::app()->user->setFlash('error', "Pastikan file yang Anda upload sudah benar!");
             $this->redirect(array('import'));
         }
     }
 }
开发者ID:jimminababan,项目名称:kontrol-anggaran,代码行数:83,代码来源:OutputController.php


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