本文整理汇总了PHP中Dataset::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Dataset::model方法的具体用法?PHP Dataset::model怎么用?PHP Dataset::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dataset
的用法示例。
在下文中一共展示了Dataset::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayDataset
public function displayDataset($ids)
{
$criteria = new CDbCriteria();
$criteria->addInCondition("id", $ids);
$datasets = Dataset::model()->findAll($criteria);
$this->generateFeed($datasets);
}
示例2: actionNotification
public function actionNotification(){
$this->lastdataset=Yii::app()->basePath."/scripts/data/lastdataset.txt";
$filecontent= $this->readFile();
$temp = json_decode($filecontent,true);
$lastdataset=isset($temp['lastdataset'])?$temp['lastdataset']:0;
$lastTimeRun=isset($temp['lastTimeRun'])?$temp['lastTimeRun']:0;
$now=microtime(true);
$lastestDataset = Dataset::model()->find("id=(SELECT MAX(id) FROM dataset)");
if(($lastestDataset->id-$lastdataset > $this->numberOfNewDataset) || ( ($now-$lastTimeRun)>$this->timeWaitPeriod ) && $lastestDataset->id-$lastdataset >0){
$newDatasets = Dataset::model()->findAll("id>?",array($lastdataset));
$content= $this->generateEmail($newDatasets);
$this->sendBroadcastEmail($this->emailSubject,$content);
// Store Information for next time
$temp['lastdataset'] = $lastestDataset->id;
$temp['lastTimeRun'] = floor($now);
$this->writeFile(json_encode($temp));
}else {
echo "Don't have enough dataset";
}
}
示例3: sendNotificationEmail
private function sendNotificationEmail($list,$user,$criteria){
$app_email_name = Yii::app()->params['app_email_name'];
$app_email = Yii::app()->params['app_email'];
$email_prefix = Yii::app()->params['email_prefix'];
$headers = "From: $app_email_name <$app_email>\r\n"; //optional header fields
$headers .= "Content-type: text/html\r\n";
ini_set('sendmail_from', $app_email);
$listurl="";
foreach ($list as $key => $value) {
$model = Dataset::model()->findByPk($value);
$url = Yii::app()->params['home_url']."/dataset/".$model->identifier;
$author_list = '';
if (count($model->authors) > 0) {
$i = 0;
foreach( $model->authors as $key => $author){
if (++$i < count($model->authors)) $author_list .= $author->name.';'; else $author_list .= $author->name.' ';
}
}
$listurl .= <<<EO_LU
<span style='font-weight:bold;'>{$model->title}</span><br>
{$author_list}<br>
<a href='{$url}'>{$url}</a><br><br>
EO_LU;
}
$recipient = Yii::app()->params['notify_email'];
$subject = "GigaDB has new content which matches your interest";
$body = CController::renderInternal(Yii::app()->basePath.'/views/search/emailMatchedSearches.php',array('listurl'=>$listurl,'criteria'=>$criteria),true);
mail($user->email, $subject, $body, $headers);
Yii::log(__FUNCTION__."> Sent email to $recipient, $subject");
}
示例4: getFullDatasetResultByKeyword
private function getFullDatasetResultByKeyword($keyword)
{
$wordCriteria = array();
$wordCriteria['keyword'] = $keyword;
$list_result_dataset_criteria = $this->searchDataset($wordCriteria);
$temp_dataset_criteria = new CDbCriteria();
$temp_dataset_criteria->addInCondition("id", $list_result_dataset_criteria);
return Dataset::model()->findAll($temp_dataset_criteria);
}
示例5: createLog
public function createLog($dataset_id, $message)
{
#only save the log when dataset is public
$dataset = Dataset::model()->findByPk($dataset_id);
if ($dataset->IsPublic) {
$log = new DatasetLog();
$log->dataset_id = $dataset_id;
$log->message = $message;
$log->model = $this->Owner->tableName();
$log->model_id = $this->Owner->id;
$log->save(false);
}
}
示例6: actionIndex
public function actionIndex()
{
$limit = 10;
$offset = 0;
while (true) {
$datasets = Dataset::model()->findAll(array("order" => "identifier ASC", "limit" => $limit, "offset" => $offset));
if (!$datasets) {
break;
}
foreach ($datasets as $dataset) {
$cite = $dataset->cited;
$dataset->citation = $cite['total'];
$dataset->save();
}
if (count($datasets) < $limit) {
break;
}
$offset = $offset + $limit;
}
}
示例7: run
public function run($args)
{
$site = '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
// datasets
foreach (Dataset::model()->findAll() as $dataset) {
$url = 'dataset/' . $dataset->identifier;
$site .= $this->createUrlBlock($url, null, 'weekly', 1.0);
}
// news
foreach (News::model()->findAll() as $newsItem) {
$url = 'news/id/' . $newsItem->id;
$site .= $this->createUrlBlock($url, null, 'weekly', 0.5);
}
// static pages
$site .= $this->createUrlBlock('site/about', null, 'yearly', 0.3);
$site .= $this->createUrlBlock('site/contact', null, 'yearly', 0.3);
$site .= $this->createUrlBlock('site/term', null, 'yearly', 0.3);
$site .= '</urlset>';
//write to file
$file = fopen(dirname(__FILE__) . "/../../sitemap.xml", 'w');
fwrite($file, $site);
fclose($file);
}
示例8: actionDatasetAjaxDelete
public function actionDatasetAjaxDelete()
{
if (isset($_POST['dataset_id'])) {
$dataset = Dataset::model()->findByPk($_POST['dataset_id']);
if (!$dataset) {
Util::returnJSON(array("success" => false, "message" => Yii::t("app", "Dataset does not exist.")));
}
if ($dataset->delete()) {
Util::returnJSON(array("success" => true));
}
}
Util::returnJSON(array("success" => false, "message" => Yii::t("app", "Delete Error.")));
}
示例9: getDatasetByType
public function getDatasetByType($type)
{
if ($type > 0) {
$models = Dataset::model()->findAllBySql("SELECT * FROM dataset JOIN dataset_type ON dataset.id=dataset_type.dataset_id WHERE dataset_type.type_id=:type_id AND dataset.upload_status = 'Published' limit 9", array(':type_id' => $type));
} else {
$models = Dataset::model()->findAllBySql("SELECT * FROM dataset WHERE dataset.upload_status = 'Published' limit 9");
}
return $models;
}
示例10: foreach
<div class="tab-content">
<?php
foreach ($datasets['data'] as $dt) {
?>
<?php
$dataset = Dataset::model()->findByPk($dt);
$dsamples = $dataset->getSamplesInIds($samples['data']);
$dfiles = $dataset->getFilesInIds($files['data']);
?>
<div class="search-result-container">
<!--Dataset section-->
<?php
$is_display = in_array('dataset', $display) || in_array('file', $display) && $dfiles || in_array('sample', $display) && $dsamples;
?>
<?php
if ($is_display) {
?>
<div class="row">
<div class="span1 logo-container"><img src="/images/icons/g-new-icon.png">
</div>
<div class="span8 main-content">
<ul class="nav nav-tabs nav-stacked result-cell">
<li><a data-content="<?php
echo MyHtml::encode($dataset->description);
?>
" class="result-main-link left content-popup" href="<?php
echo $dataset->shortUrl;
?>
"><?php
echo $dataset->title;
?>
示例11: 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);
}
}
示例12: actionCreate1
public function actionCreate1()
{
if (isset($_GET['id'])) {
$dataset_id = $_GET['id'];
} else {
Yii::app()->user->setFlash('error', "Can't retrieve the files");
$this->redirect("/user/view_profile");
}
$defaultFileSortColumn = 'dataset.name';
$defaultFileSortOrder = CSort::SORT_DESC;
if (isset($_GET['filesort'])) {
// use new sort and save to cookie
// check if desc or not
$order = substr($_GET['filesort'], strlen($_GET['filesort']) - 5, 5);
$columnName = $defaultFileSortColumn;
if ($order == '.desc') {
$columnName = substr($_GET['filesort'], 0, strlen($_GET['filesort']) - 5);
$order = 1;
} else {
$columnName = $_GET['filesort'];
$order = 0;
}
$defaultFileSortColumn = $columnName;
$defaultFileSortOrder = $order;
Yii::app()->request->cookies['file_sort_column'] = new CHttpCookie('file_sort_column', $columnName);
Yii::app()->request->cookies['file_sort_order'] = new CHttpCookie('file_sort_order', $order);
} else {
// use old sort if exists
if (isset(Yii::app()->request->cookies['file_sort_column'])) {
$cookie = Yii::app()->request->cookies['file_sort_column']->value;
$defaultFileSortColumn = $cookie;
}
if (isset(Yii::app()->request->cookies['file_sort_order'])) {
$cookie = Yii::app()->request->cookies['file_sort_order']->value;
$defaultFileSortOrder = $cookie;
}
}
$fsort = new MySort();
$fsort->attributes = array('*');
$fsort->attributes[] = "dataset.identifier";
$fsort->defaultOrder = array($defaultFileSortColumn => $defaultFileSortOrder);
$fpagination = new CPagination();
$fpagination->pageVar = 'files_page';
$files = new CActiveDataProvider('File', array('criteria' => array('condition' => "dataset_id = " . $dataset_id, 'join' => 'JOIN dataset ON dataset.id = t.dataset_id', 'order' => 't.id'), 'sort' => $fsort, 'pagination' => $fpagination));
$updateAll = 0;
if (isset($_POST['File'])) {
if (isset($_POST['files'])) {
$updateAll = 1;
}
$count = count($_POST['File']);
$page = $_POST['page'];
$pageCount = $_POST['pageCount'];
if ($page < $pageCount) {
$page++;
$files->getPagination()->setCurrentPage($page);
}
for ($i = 0; $i < $count; $i++) {
if ($updateAll == 0 && !isset($_POST[$i])) {
continue;
}
$model = $this->loadModel($_POST['File'][$i]['id']);
// $model->dataset_id = $dataset_id;
$model->attributes = $_POST['File'][$i];
if ($model->date_stamp == "") {
$model->date_stamp = NULL;
}
if (!$model->save()) {
var_dump($_POST['File'][$i]);
}
}
//determine if it want to submit
// if (isset($_POST['file'])) {
// $this->redirect("/dataset/submit");
// }
}
$dataset = Dataset::model()->findByAttributes(array('id' => $dataset_id));
$samples = $dataset->samples;
$samples_data = array();
//add none and All , Multiple
$samples_data[''] = '';
$samples_data['none'] = 'none';
$samples_data['All'] = 'All';
$samples_data['Multiple'] = 'Multiple';
foreach ($samples as $sample) {
$samples_data[$sample->name] = $sample->name;
}
$identifier = $dataset->identifier;
$action = 'create1';
$this->render($action, array('files' => $files, 'identifier' => $identifier, 'samples_data' => $samples_data, 'model' => $dataset));
}
示例13: array
$form = $this->beginWidget('CActiveForm', array('id' => 'file-form', 'enableAjaxValidation' => false, 'htmlOptions' => array('class' => 'form-horizontal')));
?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php
echo $form->errorSummary($model);
?>
<div class="control-group">
<?php
echo $form->labelEx($model, 'dataset_id', array('class' => 'control-label'));
?>
<div class="controls">
<?php
echo CHtml::activeDropDownList($model, 'dataset_id', CHtml::listData(Dataset::model()->findAll("1=1 order by identifier desc"), 'id', 'identifier'));
?>
<?php
echo $form->error($model, 'dataset_id');
?>
</div>
</div>
<div class="control-group">
<?php
echo $form->labelEx($model, 'folder_name', array('class' => 'control-label'));
?>
<a class="myHint" data-content="input the detailed ftp address, for example<br/>
aspera.gigadb.org"></a>
<div class="controls">
示例14: getDatasetsByOrder
public function getDatasetsByOrder()
{
$criteria = new CDbCriteria();
$criteria->join = 'LEFT JOIN dataset_author da on da.dataset_id = t.id';
$criteria->addCondition('da.author_id = ' . $this->id);
$criteria->order = 't.identifier asc';
return Dataset::model()->findAll($criteria);
}
示例15: actionView_Profile
public function actionView_Profile()
{
$model = new EditProfileForm();
$model->user_id = Yii::app()->user->id;
$user = $this->loadUser(Yii::app()->user->id);
$model->first_name = $user->first_name;
$model->last_name = $user->last_name;
$model->email = $user->email;
$model->affiliation = $user->affiliation;
$model->newsletter = $user->newsletter;
$model->preferred_link = $user->preferred_link;
$current = $user->newsletter;
if (isset($_POST['EditProfileForm'])) {
$model->attributes = $_POST['EditProfileForm'];
if ($model->validate()) {
if ($model->updateInfo()) {
$new = $model->newsletter;
if ($new && !$current) {
Yii::log('add new mailing', 'debug');
$success = Utils::addToMailing($model->email, array('FNAME' => $model->first_name, 'LNAME' => $model->last_name));
}
if (!$new && $current) {
Yii::log('remove mailing', 'debug');
$success = Utils::removeFromMailing($model->email);
}
$this->redirect('/user/view_profile');
}
} else {
Yii::log(print_r($model->getErrors(), true), 'debug');
}
}
$searchRecord = SearchRecord::model()->findAllByAttributes(array('user_id' => Yii::app()->user->id));
//Yii::log(print_r($searchRecord, true), 'debug');
$uploadedDatasets = Dataset::model()->findAllByAttributes(array('submitter_id' => Yii::app()->user->id), array('order' => 'upload_status'));
$this->render('view_profile', array('model' => $model, 'searchRecord' => $searchRecord, 'uploadedDatasets' => $uploadedDatasets));
}