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