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


PHP Component::save方法代码示例

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


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

示例1: actionNew

 public function actionNew()
 {
     $model = new Component();
     if (isset($_POST['Component'])) {
         $model->attributes = $_POST['Component'];
         if ($model->save(false)) {
             $this->redirect(Yii::app()->createUrl('/admin/compontent/index'));
         }
     }
     $this->render('componentAdd', array('model' => $model));
 }
开发者ID:beingsane,项目名称:joomlacreator,代码行数:11,代码来源:ComponentController.php

示例2: save_edit

 public function save_edit()
 {
     if (!isset($_SESSION['logged'])) {
         return call('pages', 'home');
     } else {
         if (!isset($_GET['code'])) {
             return call('pages', 'error', 2);
         }
         $post_data = $_POST;
         Component::save($post_data, $_GET['code']);
         return call('components', 'index');
     }
 }
开发者ID:ScalateKids,项目名称:Scalatetrack,代码行数:13,代码来源:components_controller.php

示例3: importExcelToMysql

 public function importExcelToMysql($filePath, $fields = array(), $model = null, $startingRow = 2)
 {
     $objPHPExcel = PHPExcel_IOFactory::load($filePath);
     foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
         //field validation
         $fieldValidate = array();
         for ($col = 0; $col < count($fields); ++$col) {
             $val = $worksheet->getCellByColumnAndRow($fields[$col]['col'], 1)->getValue();
             $fieldValidate[$fields[$col]['name']] = $val;
         }
         $validated = FALSE;
         if ($fieldValidate['satker_code'] == 'Kode Satker' and $fieldValidate['activity_code'] == 'Kode Kegiatan' and $fieldValidate['output_code'] == 'Kode Output' and $fieldValidate['suboutput_code'] == 'Kode Suboutput' and $fieldValidate['code'] == 'Kode Komponen' and $fieldValidate['name'] == 'Uraian Komponen') {
             $validated = TRUE;
         }
         //end of validation
         if ($validated == TRUE) {
             $highestRow = $worksheet->getHighestRow();
             $isSuccess = FALSE;
             //check if RKAKL data subcomponent already removed, but app master data already realize
             $this->validateRemovedData($filePath, $fields, $worksheet, $highestRow, $startingRow);
             for ($row = $startingRow; $row <= $highestRow; ++$row) {
                 $attributes = array();
                 for ($col = 0; $col < count($fields); ++$col) {
                     $val = $worksheet->getCellByColumnAndRow($fields[$col]['col'], $row)->getValue();
                     $attributes[$fields[$col]['name']] = $val;
                 }
                 $suboutputcode = trim($attributes['satker_code'], " \t\n\r\v") . '.' . trim($attributes['activity_code'], " \t\n\r\v") . '.' . trim($attributes['output_code'], " \t\n\r\v") . '.' . trim($attributes['suboutput_code'], " \t\n\r\v");
                 $code = $suboutputcode . '.' . trim($attributes['code'], " \t\n\r\v");
                 $recorded = Component::model()->find(array('condition' => "code='{$code}'"));
                 if ($attributes['satker_code'] != NULL and $attributes['activity_code'] != NULL and $attributes['output_code'] != NULL and $attributes['suboutput_code'] != NULL and $attributes['code'] != NULL and $attributes['name'] != NULL) {
                     if ($recorded) {
                         $recorded->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['output_code']) ? trim($attributes['output_code'], " \t\n\r\v") : NULL;
                         $suboutputCode = isset($attributes['suboutput_code']) ? trim($attributes['suboutput_code'], " \t\n\r\v") : NULL;
                         $subcomponentCode = isset($attributes['code']) ? trim($attributes['code'], " \t\n\r\v") : NULL;
                         //set value
                         $recorded->satker_code = $satkerCode;
                         $recorded->activity_code = $satkerCode . '.' . $activityCode;
                         $recorded->output_code = $satkerCode . '.' . $activityCode . '.' . $outputCode;
                         $recorded->suboutput_code = $satkerCode . '.' . $activityCode . '.' . $outputCode . '.' . $suboutputCode;
                         $recorded->code = $satkerCode . '.' . $activityCode . '.' . $outputCode . '.' . $suboutputCode . '.' . $subcomponentCode;
                         if ($recorded->update()) {
                             $isSuccess = TRUE;
                         }
                     } else {
                         $model = new Component();
                         $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['output_code']) ? trim($attributes['output_code'], " \t\n\r\v") : NULL;
                         $suboutputCode = isset($attributes['suboutput_code']) ? trim($attributes['suboutput_code'], " \t\n\r\v") : NULL;
                         $componentCode = isset($attributes['code']) ? trim($attributes['code'], " \t\n\r\v") : NULL;
                         //set value
                         $model->satker_code = $satkerCode;
                         $model->activity_code = $satkerCode . '.' . $activityCode;
                         $model->output_code = $satkerCode . '.' . $activityCode . '.' . $outputCode;
                         $model->suboutput_code = $satkerCode . '.' . $activityCode . '.' . $outputCode . '.' . $suboutputCode;
                         $model->code = $satkerCode . '.' . $activityCode . '.' . $outputCode . '.' . $suboutputCode . '.' . $componentCode;
                         if ($model->save()) {
                             $isSuccess = TRUE;
                         }
                     }
                 }
             }
             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 masukkan 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,代码行数:81,代码来源:ComponentController.php

示例4: save

 function save()
 {
     $this->filter_access('Component', 'roled_add', 'components/index');
     $component = new Component();
     $component->comp_name = $this->input->post('comp_name');
     $component->comp_type = $this->input->post('comp_type');
     if ($component->save()) {
         $this->session->set_flashdata('message', 'Component successfully created!');
         redirect('components/');
     } else {
         // Failed
         $component->error_message('custom', 'Component Name required');
         $msg = $component->error->custom;
         $this->session->set_flashdata('message', $msg);
         redirect('components/add');
     }
 }
开发者ID:anggadjava,项目名称:payroll,代码行数:17,代码来源:components.php


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