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


PHP Sample::model方法代码示例

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


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

示例1: run

 public function run()
 {
     echo 'Massive Run for samples';
     $biobanks = Biobank::model()->findAll();
     foreach ($biobanks as $biobank) {
         $modifier = new EMongoModifier();
         $modifier->addModifier('biobank_id', 'set', (string) $biobank->_id);
         $criteria = new EMongoCriteria();
         $criteria->biobank_id = $biobank->id;
         $status = Sample::model()->updateAll($modifier, $criteria);
         $criteriaAfter = new EMongoCriteria();
         $criteriaAfter->biobank_id = (string) $biobank->_id;
         $count = Sample::model()->count($criteriaAfter);
         echo "Done for biobank {$biobank->_id} - {$biobank->name} : {$count}\n";
     }
 }
开发者ID:nmalservet,项目名称:biocap,代码行数:16,代码来源:changeIdSampleCommand.php

示例2: actionDelete

 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     $model = $this->loadModel($id);
     $name = $model->name;
     $sampleCount = Sample::model()->countByAttributes(array('biobank_id' => (string) $model->id));
     $adminCount = User::model()->countByAttributes(array('biobank_id' => (string) $model->_id));
     if ($adminCount == 0 && $sampleCount == 0) {
         try {
             $model->delete();
             Yii::app()->user->setFlash('success', 'La biobanque a bien été supprimée.');
         } catch (Exception $ex) {
             Yii::app()->user->setFlash('error', 'La biobanque n\'a pas pu être supprimée : ' . $ex->getMessage());
         }
     } else {
         $message = "Suppression de la biobanque \"{$name}\" impossible : ";
         if ($adminCount > 0) {
             $message .= "<br> - Il reste {$adminCount} administrateur(s) lié(s) à la biobanque.";
         }
         if ($sampleCount > 0) {
             $message .= "<br> reste {$sampleCount} échantillon(s) lié(s) à la biobanque.";
         }
         Yii::app()->user->setFlash('error', $message);
     }
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
     if (!isset($_GET['ajax'])) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
     } else {
         $flashMessages = Yii::app()->user->getFlashes();
         $flashMessagesHtml = '';
         if ($flashMessages) {
             foreach ($flashMessages as $key => $message) {
                 $flashMessagesHtml .= '<br><div class="flash-' . $key . '">' . $message . "</div>";
             }
         }
         echo $flashMessagesHtml;
     }
 }
开发者ID:nmalservet,项目名称:biocap,代码行数:42,代码来源:BiobankController.php

示例3: loadEchModel

 public function loadEchModel($id)
 {
     $model = Sample::model()->findByPk(new MongoID($id));
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:nmalservet,项目名称:biocap,代码行数:8,代码来源:MybiobankController.php

示例4: array

        <?php 
echo CHtml::activeDropDownList($model, 'dataset_id', CHtml::listData(Util::getDois(), 'id', 'identifier'));
?>
		<?php 
echo $form->error($model, 'dataset_id');
?>
				</div>
	</div>

	<div class="control-group">
		<?php 
echo $form->labelEx($model, 'sample_id', array('class' => 'control-label'));
?>
				<div class="controls">
        <?php 
echo CHtml::activeDropDownList($model, 'sample_id', CHtml::listData(Sample::model()->findAll(), 'id', 'id'));
?>
		<?php 
echo $form->error($model, 'sample_id');
?>
				</div>
	</div>

	<div class="row buttons">
        <a href="/adminDatasetSample/admin" class="btn">Cancel</a>
		<?php 
echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('class' => 'btn'));
?>
	</div>

<?php 
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:31,代码来源:_form.php

示例5: getCompletionRateByBiobank

 /**
  * effectue le calcul de statistiques de la biobanque fournie en parametre si elle possede des echantillons,
  * @param type $biobank_id
  * @return null
  */
 public static function getCompletionRateByBiobank($biobank_id)
 {
     //nombre total d'échantillons de la biobanque
     $criteria = new EMongoCriteria();
     $criteria->biobank_id = $biobank_id;
     $compte = Sample::model()->count($criteria);
     if ($compte != 0 && $compte != null) {
         $details = array();
         $rateCount = 0;
         $listAttributes = StatTools::getAttributesForRating();
         foreach ($listAttributes as $attributeName => $attributeConstraint) {
             $echCriteria = new EMongoCriteria();
             $echCriteria->biobank_id = $biobank_id;
             $echCriteria->addCond($attributeName, "exists", true);
             if (is_array($attributeConstraint)) {
                 foreach ($attributeConstraint as $operator => $values) {
                     $echCriteria->addCond($attributeName, $operator, $values);
                 }
             }
             $nbEch = Sample::model()->count($echCriteria);
             $details[$attributeName] = round($nbEch / $compte * 100, 2);
             $rateCount += $nbEch;
         }
         $rate = $rateCount / ($compte * count($listAttributes));
         return array($rate * 100, $details);
     } else {
         return null;
     }
 }
开发者ID:nmalservet,项目名称:biocap,代码行数:34,代码来源:StatTools.php

示例6: if

<h1>View File #<?php 
echo $model->id;
?>
</h1>
<? if (Yii::app()->user->checkAccess('admin')) { ?>
<div class="actionBar">
[<?php 
echo MyHtml::link('Manage Files', array('admin'));
?>
]
</div>
<? } ?>

<?php 
$sample_id = FileSample::model()->find('file_id=:file_id', array(':file_id' => $model->id));
if (isset($sample_id)) {
    $sample_name = Sample::model()->find('id=:id', array(':id' => $sample_id->sample_id));
}
$name = "Not Set";
if (isset($sample_id) && isset($sample_name)) {
    $name = $sample_name->name;
}
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'dataset_id', 'name', 'location', 'extension', 'size', 'description', 'date_stamp', 'format_id', 'type_id', array('name' => 'Sample', 'value' => $name))));
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:23,代码来源:view.php

示例7: foreach

    $tabCount = 0;
    foreach ($globalStats[0]->values as $attributeName => $attribute) {
        $datas = array();
        for ($i = 0; $i <= $max; $i++) {
            if (isset($biobankStats[$max - $i])) {
                $datas['biobanque'][] = $biobankStats[$max - $i]->values[$attributeName];
            } else {
                $datas['biobanque'][] = null;
            }
            if (isset($globalStats[$max - $i])) {
                $datas['global'][] = $globalStats[$max - $i]->values[$attributeName];
            } else {
                $datas['global'][] = null;
            }
        }
        $listWidgets[$attributeName] = array('label' => Sample::model()->getAttributeLabel($attributeName), 'url' => Yii::app()->createUrl('mybiobank/detailGraph'), 'ajax' => array('type' => 'POST', 'update' => '#detailData', 'data' => array('datas' => $datas, 'attributeName' => $attributeName, 'theme' => $theme)));
    }
    ?>

    <div style="overflow: hidden;display: inline-block">
        <div id="detailsMenu" style="float:left;width:200px;padding-left:5px;padding-right:5px;padding-top:5px;">
            <div class="span-5 last">
                <?php 
    $this->beginWidget('zii.widgets.CPortlet', array('title' => 'Détails'));
    $this->widget('ext.AjaxMenu', array('items' => $listWidgets));
    $this->endWidget();
    ?>

            </div></div>

开发者ID:nmalservet,项目名称:biocap,代码行数:29,代码来源:benchmarking.php

示例8: getAllSamples

 public function getAllSamples()
 {
     $criteria = new CdbCriteria();
     $criteria->join = "join dataset_sample ds on ds.sample_id = t.id";
     $criteria->addCondition("ds.dataset_id = " . $this->id);
     return Sample::model()->findAll($criteria);
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:7,代码来源:Dataset.php

示例9: getSamples

 public function getSamples()
 {
     $samples = array();
     if ($this->sampleList != null) {
         foreach ($this->sampleList as $sampleDemand) {
             $samples[] = new MongoID($sampleDemand->id_sample);
         }
     }
     $dataProvider = Sample::model()->getSamplesFromArray($samples);
     return $dataProvider;
 }
开发者ID:nmalservet,项目名称:biocap,代码行数:11,代码来源:Demande.php

示例10: actionPrint

 /**
  * print de la liste dechantillons
  */
 public function actionPrint()
 {
     // $model = new Sample('search');
     if (isset($_SESSION['criteria']) && $_SESSION['criteria'] != null && $_SESSION['criteria'] instanceof EMongoCriteria) {
         $criteria = $_SESSION['criteria'];
     } else {
         $criteria = new EMongoCriteria();
     }
     $criteria->limit(200);
     $dataProvider = new EMongoDocumentDataProvider('Sample', array('criteria' => $criteria, 'pagination' => false));
     $columns = array();
     foreach (Sample::model()->attributeExportedLabels() as $key => $value) {
         if ($key == 'notes') {
             $columns[] = $this->addColumn($key, $value, '$data->getShortNotes()');
         } elseif ($key == 'biobank_id') {
             $columns[] = $this->addColumn('biobank_id', $value, '$data->getBiobankName()');
         } elseif ($key == 'collect_date') {
             $columns[] = $this->addColumn('collect_date', $value, '$data->collect_date');
             //TODO normaliser les dates de collecte avant d activer cette feature
             // $columns [] = getArrayColumn('collect_date', $value, 'CommonTools::toShortDateFR($data->collect_date)');
         } elseif ($key == 'storage_conditions') {
             $columns[] = $this->addColumn('storage_conditions', $value, '$data->getLiteralStorageCondition()');
         } else {
             $columns[] = $this->addColumn($key, $value, '$data->' . $key);
         }
     }
     $this->render('print', array('dataProvider' => $dataProvider, 'columns' => $columns));
 }
开发者ID:nmalservet,项目名称:biocap,代码行数:31,代码来源:SearchSamplesController.php

示例11: array

            $visibility = 'display:none';
        }
        if ($property == 'notes') {
            $columns[] = array('class' => 'DataColumn', 'name' => $property, 'id' => 'col_' . $property, 'header' => Sample::model()->getAttributeLabel($property), 'value' => '$data->getShortNotes()', 'htmlOptions' => array('class' => "col_{$property}", 'style' => $visibility), 'headerHtmlOptions' => array('class' => "col_{$property}", 'style' => $visibility));
        } elseif ($property == 'biobank_id') {
            $columns[] = array('class' => 'DataColumn', 'name' => Yii::t('sample', 'biobank_id'), 'id' => 'col_' . $property, 'header' => Sample::model()->getAttributeLabel($property), 'value' => 'Biobank::model()->findByPk(new MongoId($data->biobank_id))->name', 'htmlOptions' => array('class' => "col_{$property}", 'style' => $visibility), 'headerHtmlOptions' => array('class' => "col_{$property}", 'style' => $visibility));
        } elseif ($property == 'collect_date') {
            $columns[] = array('class' => 'DataColumn', 'name' => $property, 'id' => 'col_' . $property, 'header' => Sample::model()->getAttributeLabel($property), 'value' => 'CommonTools::toShortDateFR($data->collect_date)', 'htmlOptions' => array('class' => "col_{$property}", 'style' => $visibility), 'headerHtmlOptions' => array('class' => "col_{$property}", 'style' => $visibility));
        } elseif ($property == 'storage_conditions') {
            $columns[] = array('class' => 'DataColumn', 'name' => $property, 'id' => 'col_' . $property, 'header' => Sample::model()->getAttributeLabel($property), 'value' => '$data->getLiteralStorageCondition()', 'htmlOptions' => array('class' => "col_{$property}", 'style' => $visibility), 'headerHtmlOptions' => array('class' => "col_{$property}", 'style' => $visibility));
        } elseif ($property == 'collection_name') {
            $columns[] = addColumn('collection_name', Biobank::model()->getAttributeLabel('collection_name'), '$data->biobank->collection_name', $visibility);
        } elseif ($property == 'collection_id') {
            $columns[] = addColumn('collection_id', Biobank::model()->getAttributeLabel('collection_id'), '$data->biobank->collection_id', $visibility);
        } else {
            $columns[] = array('class' => 'DataColumn', 'name' => $property, 'id' => 'col_' . $property, 'value' => '$data->' . $property, 'header' => Sample::model()->getAttributeLabel($property), 'htmlOptions' => array('class' => "col_{$property}", 'style' => $visibility), 'headerHtmlOptions' => array('class' => "col_{$property}", 'style' => $visibility));
        }
    }
}
//
$columns[] = array('header' => Yii::t('demande', 'sampleDetail'), 'class' => 'CLinkColumn', 'labelExpression' => '$data->_id', 'urlExpression' => 'Yii::app()->createUrl("site/view",array("id"=>"$data->_id"))', 'linkHtmlOptions' => array('onclick' => 'window.open(this.href,"SampleDetail","left=100,top=100,width=760,height=650,toolbar=0,resizable=0, location=no");return false;'), 'htmlOptions' => array('style' => 'text-align:center'), 'imageUrl' => $imageSampleDetail);
?>

<h1><?php 
echo Yii::t('common', 'demande') . ' ' . $model->titre;
?>
</h1>

<?php 
echo $this->renderPartial('_form', array('model' => $model));
?>
开发者ID:nmalservet,项目名称:biocap,代码行数:31,代码来源:update.php

示例12: actionDelete1

 public function actionDelete1($id)
 {
     if (isset($_SESSION['samples'])) {
         $info = $_SESSION['samples'];
         foreach ($info as $key => $value) {
             if ($value['id'] == $id) {
                 unset($info[$key]);
                 $_SESSION['samples'] = $info;
                 $vars = array('samples');
                 //Dataset::storeSession($vars);
                 $condition = 'id=' . $id;
                 $sample_id = DatasetSample::model()->findByAttributes(array('id' => $id))->sample_id;
                 DatasetSample::model()->deleteAll($condition);
                 Sample::model()->deleteAll('id=' . $sample_id);
                 $this->redirect("/adminDatasetSample/create1");
             }
         }
     }
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:19,代码来源:AdminDatasetSampleController.php

示例13: testgetShortNotes

 public function testgetShortNotes()
 {
     $sample = Sample::model();
     $this->assertNotNull($sample);
     //$sample=Sample::model()->search());
 }
开发者ID:nmalservet,项目名称:biocap,代码行数:6,代码来源:SampleTest.php

示例14: round

if ($stats != null) {
    $complete = $stats->globalRate;
} else {
    $complete = 0;
}
$roundcomplete = round($complete);
$uncomplete = 100 - $roundcomplete;
$data = array(array('Complet : ' . $roundcomplete . '%', $roundcomplete), array('Incomplet : ' . $uncomplete . "%", $uncomplete));
$this->beginWidget('zii.widgets.CPortlet', array('title' => "<i class = 'icon-adjust'></i> " . Yii::t('myBiobank', 'samplesCompletionRate') . " -  {$model->identifier}"));
// affichage du graphe de completude des echantillons
$this->widget('application.widgets.charting.CPieChartWidget', array('id' => 'piechart-collab', 'theme' => 'WatersEdge', 'width' => 380, 'height' => 250, 'data' => $data, 'title' => '<a class="detail-button" href="#">détails</a>'));
$this->endWidget();
?>
    </div>

    <!-- affichage du tableau de stats detaillées -->
    <div style="float: left; width: 330px; padding-left: 10px; padding-top: 10px; display: none" class="detail_tab">
        <h4><b>Détails des taux de complétude.</b></h4>
        <?php 
if ($stats != null) {
    foreach ($stats->values as $valueName => $value) {
        $attributes[] = array('label' => Sample::model()->getAttributeLabel($valueName), 'value' => $value . '%');
    }
    $this->widget('zii.widgets.CDetailView', array('data' => $stats->values, 'attributes' => $attributes));
    ?>
        </div>
    </div>
    <div style="clear: both;" />

    <?php 
}
开发者ID:nmalservet,项目名称:biocap,代码行数:31,代码来源:index.php

示例15: analyzeCsv

 protected static function analyzeCsv($bytes, $biobank_id, $fileImportedId, $add)
 {
     $import = fopen(CommonTools::data_uri($bytes, 'text/csv'), 'r');
     $row = 1;
     $keysArray = array();
     $listBadSamples = array();
     $newSamples = array();
     //        $tempSaveList = new MongoInsertBatch(Sample::model()->getCollection());
     $tempSaveList = array();
     /**
      * Version 1 : Les champs non repertorés sont ajoutés en notes
      */
     while (($data = fgetcsv($import, 1000, ",")) !== FALSE) {
         /*
          * Traitement de la ligne d'entete
          */
         if ($row == 1) {
             foreach ($data as $key => $value) {
                 if ($value != null && $value != "") {
                     $keysArray[$key] = $value;
                 }
             }
         } else {
             $model = new Sample();
             $model->disableBehavior('LoggableBehavior');
             $model->_id = new MongoId();
             while (!$model->validate(array('_id'))) {
                 $model->_id = new MongoId();
             }
             $model->biobank_id = $biobank_id;
             $model->file_imported_id = $fileImportedId;
             foreach ($keysArray as $key2 => $value2) {
                 if ($value2 != "biobank_id" && $value2 != "file_imported_id") {
                     if (in_array($value2, Sample::model()->attributeNames())) {
                         $model->{$value2} = $data[$key2];
                         if (!$model->validate(array($value2))) {
                             //   Yii::log("Problem with item" . $model->getAttributeLabel($value2) . ",set to null.\n " . implode(", ", $model->errors[$value2]), CLogger::LEVEL_ERROR);
                             $model->{$value2} = null;
                         }
                     } else {
                         $note = new Note();
                         $note->key = $value2;
                         $note->value = $data[$key2];
                         $model->notes[] = $note->attributes;
                     }
                 }
             }
             if (!$model->validate()) {
                 Yii::log("Problem with sample validation " . print_R($model->errors, true), CLogger::LEVEL_ERROR);
                 $listBadSamples[] = $row;
             } else {
                 $tempSaveList[] = $model->attributes;
                 //                        $tempSaveList->add($model->attributes);
                 $newSamples[] = $model->_id;
             }
         }
         $row++;
         if ($row != 2 && $row % 400 == 2) {
             Yii::log("Nb treated : " . $row, 'error');
             Sample::model()->getCollection()->batchInsert($tempSaveList, array());
             $tempSaveList = array();
             //$tempSaveList->execute(array());
             //$tempSaveList = new MongoInsertBatch(Sample::model()->getCollection());
         }
     }
     Sample::model()->getCollection()->batchInsert($tempSaveList, array("w" => 1));
     /*
      * Version 2 : seuls nes champs dont la colonne est annotée avec le préfixe 'notes' sont pris en note
      */
     //        while (($data = fgetcsv($import, 1000, ",")) !== FALSE) {
     //
     //            /*
     //             * Traitement de la ligne d'entete
     //             */
     //
     //
     //
     //            if ($row == 1) {
     //                foreach ($data as $key => $value) {
     //                    if (in_array($value, Sample::model()->attributeNames())) {
     //                        $keysArray[$key] = $value;
     //                    } elseif (substr($value, 0, 5) == 'notes') {
     //                        $keysArray[$key] = $value;
     //                    }
     //                }
     //                /*
     //                 * Traitement des lignes de données
     //                 */
     //            } else {
     //                $model = new Sample();
     //                $model->disableBehavior('LoggableBehavior');
     //                $model->biobank_id = $biobank_id;
     //                $model->file_imported_id = $fileImportedId;
     //                foreach ($keysArray as $key2 => $value2) {
     //                    if (substr($value2, 0, 5) != 'notes') {
     //
     //                        $model->$value2 = $data[$key2];
     //                        if (!$model->validate($value2)) {
     //
     //                            Yii::log("Problem with item" . $model->getAttributeLabel($value2) . ",set to null.", CLogger::LEVEL_ERROR);
//.........这里部分代码省略.........
开发者ID:nmalservet,项目名称:biocap,代码行数:101,代码来源:CommonTools.php


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