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


PHP Dataset::save方法代码示例

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


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

示例1: storeDataset

 public function storeDataset()
 {
     if (isset($_SESSION['dataset']) && isset($_SESSION['images'])) {
         $dataset = new Dataset();
         $dataset->image = new Images();
         $result = Dataset::model()->findAllBySql("select identifier from dataset order by identifier desc limit 1;");
         $max_doi = $result[0]->identifier;
         $identifier = $max_doi + 1;
         $dataset_id = 0;
         $dataset->attributes = $_SESSION['dataset'];
         $dataset->image->attributes = $_SESSION['images'];
         $dataset->identifier = $identifier;
         $dataset->dataset_size = 0;
         $dataset->ftp_site = "";
         if ($dataset->publication_date == "") {
             $dataset->publication_date = null;
         }
         if ($dataset->modification_date == "") {
             $dataset->modification_date = null;
         }
         if ($dataset->image->validate('update') && $dataset->validate('update') && $dataset->image->save()) {
             // save image
             $dataset->image_id = $dataset->image->id;
             if ($dataset->save()) {
                 $dataset_id = $dataset->id;
                 // link datatypes
                 if (isset($_SESSION['datasettypes'])) {
                     $datasettypes = $_SESSION['datasettypes'];
                     foreach ($datasettypes as $id => $datasettype) {
                         $newDatasetTypeRelationship = new DatasetType();
                         $newDatasetTypeRelationship->dataset_id = $dataset->id;
                         $newDatasetTypeRelationship->type_id = $id;
                         $newDatasetTypeRelationship->save();
                     }
                 }
             }
         }
         return array($dataset_id, $identifier);
     }
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:40,代码来源:AdminSampleController.php

示例2: actionCreate1

 public function actionCreate1()
 {
     $dataset = new Dataset();
     $image = new Images();
     // set default types
     $dataset->types = array();
     if (isset($_POST['Dataset']) && isset($_POST['Images'])) {
         $transaction = Yii::app()->db->beginTransaction();
         try {
             #save dataset
             $dataset->submitter_id = Yii::app()->user->_id;
             $attrs = $_POST['Dataset'];
             $dataset->title = $attrs['title'];
             $dataset->description = $attrs['description'];
             $dataset->upload_status = "Incomplete";
             $dataset->ftp_site = "''";
             // save dataset types
             if (isset($_POST['datasettypes'])) {
                 $dataset->types = $_POST['datasettypes'];
             }
             $lastDataset = Dataset::model()->find(array('order' => 'identifier desc'));
             $lastIdentifier = intval($lastDataset->identifier);
             if (!is_int($lastIdentifier)) {
                 $transaction->rollback();
                 $this->redirect('/');
             }
             $dataset->identifier = $lastIdentifier + 1;
             if ($_POST['Dataset']['union'] == 'B') {
                 $dataset->dataset_size = $_POST['Dataset']['dataset_size'];
             } else {
                 if ($_POST['Dataset']['union'] == 'M') {
                     $dataset->dataset_size = $_POST['Dataset']['dataset_size'] * 1024 * 1024;
                 } else {
                     if ($_POST['Dataset']['union'] == 'G') {
                         $dataset->dataset_size = $_POST['Dataset']['dataset_size'] * 1024 * 1024 * 1024;
                     } else {
                         if ($_POST['Dataset']['union'] == 'T') {
                             $dataset->dataset_size = $_POST['Dataset']['dataset_size'] * 1024 * 1024 * 1024 * 1024;
                         }
                     }
                 }
             }
             #save image
             if (!$_POST['Images']['is_no_image']) {
                 $uploadedFile = CUploadedFile::getInstance($image, 'image_upload');
                 $fileName = "{$uploadedFile}";
                 $path = Yii::getPathOfAlias('webroot') . "/images/uploads/" . $fileName;
                 $image->image_upload = $uploadedFile;
                 $image->url = $path;
                 $image->location = $fileName;
                 $image->tag = $_POST['Images']['tag'];
                 $image->license = $_POST['Images']['license'];
                 $image->photographer = $_POST['Images']['photographer'];
                 $image->source = $_POST['Images']['source'];
             } else {
                 $image->url = "http://gigadb.org/images/data/cropped/no_image.png";
                 $image->location = "no_image.jpg";
                 $image->tag = "no image icon";
                 $image->license = "Public domain";
                 $image->photographer = "GigaDB";
                 $image->source = "GigaDB";
             }
             if ($dataset->save() && $image->save()) {
                 $dataset->image_id = $image->id;
                 $dataset->save(false);
                 if (isset($_POST['datasettypes'])) {
                     $types = DatasetType::storeDatasetTypes($dataset->id, $_POST['datasettypes']);
                     if (!$types) {
                         $transaction->rollback();
                         $this->redirect('/');
                     }
                 }
                 $transaction->commit();
                 $this->redirect(array('/dataset/authorManagement', 'id' => $dataset->id));
             }
         } catch (Exception $e) {
             $message = $e->getMessage();
             Yii::log(print_r($message, true), 'error');
             $transaction->rollback();
             $this->redirect('/');
         }
     }
     $this->render('create1', array('model' => $dataset, 'image' => $image));
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:84,代码来源:DatasetController.php


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