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


PHP Part::save方法代码示例

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


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

示例1: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Part();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Part'])) {
         $model->attributes = $_POST['Part'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:ever4vr,项目名称:maestro,代码行数:17,代码来源:PartController.php

示例2: savePart

        private function savePart()
        {
            $form = 'frost.views.cms.part.text.TextAdd';
            $part = Part::addMediaToPart($form,'Text');
            
            // Add the 'preview' to the part 
            $part = new Part();
            $part->clauseSafe('part_id',Application::param('part_id')); 
            $part->parse(); 
            $part->save();

            //Part::setParttagsAndSave($part,Application::param('current_tags'));
    
            Application::setParam('module_id',Application::param('module_id'));
            Application::redirect('ModuleDetail');
        }
开发者ID:k7n4n5t3w4rt,项目名称:SeeingSystem,代码行数:16,代码来源:text_add.class.php

示例3: addquestions

 public function addquestions($filename)
 {
     PHPExcel_Settings::setCacheStorageMethod(PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip);
     $files = scandir("./upload");
     array_shift($files);
     array_shift($files);
     $errors = array();
     $factors = array();
     $j = 0;
     $this->db->begin();
     foreach ($files as $file) {
         if (strstr($file, $filename)) {
             $objexcel = PHPExcel_IOFactory::load("./upload/" . $file);
             $factorsheet = $objexcel->getSheet(0);
             $questionsheet = $objexcel->getSheet(1);
             $part = new Part();
             $part->type = 0;
             $part->name = (string) $factorsheet->getCell("B2")->getValue();
             $part->description = (string) $factorsheet->getCell("B3")->getValue();
             try {
                 if (!$part->save()) {
                     $errors[$j]['error'] = "part";
                     foreach ($part->getMessages() as $key => $message) {
                         $errors[$j][$key] = $message;
                     }
                     $j++;
                     $this->db->rollback();
                     $objexcel->disconnectWorksheets();
                     unlink("./upload/" . $file);
                     return $errors;
                 } else {
                     $higestrow = $factorsheet->getHighestRow();
                     $i = 5;
                     while ($i <= $higestrow) {
                         $factor = new Factor();
                         $factor->ratio = $factorsheet->getCell("B" . $i)->getValue();
                         $k = $factorsheet->getCell("A" . $i)->getValue();
                         if (is_null($k) || $k == "") {
                             break;
                         }
                         if ($factor->save()) {
                             $factors["{$k}"] = $factor->f_id;
                             $fprel = new Fprel();
                             $fprel->factor_id = $factor->f_id;
                             $fprel->part_id = $part->p_id;
                             if (!$fprel->save()) {
                                 $errors[$j]['error'] = "fprel";
                                 foreach ($fprel->getMessages() as $key => $message) {
                                     $errors[$j][$key] = $message;
                                 }
                                 $j++;
                                 $this->db->rollback();
                                 $objexcel->disconnectWorksheets();
                                 unlink("./upload/" . $file);
                                 return $errors;
                             }
                         } else {
                             $errors[$j]['error'] = "factor";
                             foreach ($factor->getMessages() as $key => $message) {
                                 $errors[$j][$key] = $message;
                             }
                             $j++;
                             $this->db->rollback();
                             $objexcel->disconnectWorksheets();
                             unlink("./upload/" . $file);
                             return $errors;
                         }
                         $i++;
                     }
                     $higestrow = $questionsheet->getHighestRow();
                     //不可靠
                     $i = 3;
                     while ($i <= $higestrow) {
                         $question = new Question();
                         $topic = (string) $questionsheet->getCell("A" . $i)->getValue();
                         if (is_null($topic) || $topic == "") {
                             break;
                         }
                         $question->topic = $topic;
                         $question->factor_id = $factors[$questionsheet->getCell("C" . $i)->getValue()];
                         $question->options = "";
                         $question->grade = "";
                         $col = "D";
                         $colnum = $questionsheet->getCell("B" . $i)->getValue();
                         for ($k = 1; $k <= $colnum; $k++, $col++) {
                             $str = $questionsheet->getCell($col . $i)->getValue();
                             $mem = explode("|", $str);
                             $question->options .= "|" . $mem[0];
                             $question->grade .= "|" . $mem[1];
                         }
                         $question->options = substr($question->options, 1);
                         $question->grade = substr($question->grade, 1);
                         if (!$question->save()) {
                             $errors[$j]['error'] = "question";
                             $errors[$j]['maxrow'] = $higestrow;
                             foreach ($question->getMessages() as $key => $message) {
                                 $errors[$j][$key] = $message;
                             }
                             $j++;
                             $this->db->rollback();
//.........这里部分代码省略.........
开发者ID:sify21,项目名称:Question,代码行数:101,代码来源:AdminController.php


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