當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Dataset::validate方法代碼示例

本文整理匯總了PHP中Dataset::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dataset::validate方法的具體用法?PHP Dataset::validate怎麽用?PHP Dataset::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Dataset的用法示例。


在下文中一共展示了Dataset::validate方法的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: actionCreate

 public function actionCreate()
 {
     $dataset = new Dataset();
     $dataset->image = new Images();
     if (isset($_POST['Dataset']) && isset($_POST['Images'])) {
         $dataset->attributes = $_POST['Dataset'];
         $dataset->image->attributes = $_POST['Images'];
         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;
             // save dataset
             if ($dataset->save()) {
                 // link datatypes
                 if (isset($_POST['datasettypes'])) {
                     $datasettypes = $_POST['datasettypes'];
                     foreach ($datasettypes as $id => $datasettype) {
                         $newDatasetTypeRelationship = new DatasetType();
                         $newDatasetTypeRelationship->dataset_id = $dataset->id;
                         $newDatasetTypeRelationship->type_id = $id;
                         $newDatasetTypeRelationship->save();
                     }
                 }
                 Yii::app()->user->setFlash('saveSuccess', 'saveSuccess');
                 if ($dataset->upload_status == 'Pending') {
                     $this->redirect('/dataset/private/identifier/' . $dataset->identifier);
                 } else {
                     $this->redirect(array('/dataset/' . $dataset->identifier));
                 }
             }
         }
     }
     $this->render('create', array('model' => $dataset));
 }
開發者ID:jessesiu,項目名稱:GigaDBV3,代碼行數:39,代碼來源:DatasetController.php


注:本文中的Dataset::validate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。