本文整理汇总了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);
}
示例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'));
}
}
}