Example #1
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search($caseSensitive = false)
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new EMongoCriteria();
     if ($this->nom != null) {
         $criteria->addCond('nom', '==', new MongoRegex('/' . $this->nom . '*/i'));
     }
     if ($this->prenom != null) {
         $criteria->addCond('prenom', '==', new MongoRegex('/' . $this->name . '*/i'));
     }
     //always sort with alphabetical order
     $criteria->sort('nom', EMongoCriteria::SORT_ASC);
     return new EMongoDocumentDataProvider($this, array('criteria' => $criteria));
 }
Example #2
0
 /**
  * 操作日志列表
  * @author gentle
  */
 public function actionIndex()
 {
     $data = array();
     $attr = $this->_logObj->attributeLabels();
     $criteria = new EMongoCriteria();
     //其他人无法看见admin的操作记录
     if (Yii::app()->user->name != 'admin') {
         $criteria->addCond('uname', '!=', 'admin');
     }
     //添加查询条件
     if (isset($_GET['sub'])) {
         $criteria = $this->fillCond($criteria, $this->_logObj->attributeLabels());
     }
     //         FunctionUTL::Debug($criteria);
     $count = $this->_logObj->count($criteria);
     $pages = new CPagination($count);
     $perPage = 20;
     $pages->pageSize = $perPage;
     $offset = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $offset = ($offset - 1) * $perPage;
     $criteria->limit($perPage)->offset($offset)->sort('id', EMongoCriteria::SORT_DESC);
     $logModel = $this->_logObj->findAll($criteria);
     $data['logModels'] = $logModel;
     $data['pages'] = $pages;
     $data['attr'] = $attr;
     //模型属性
     $this->render('index', $data);
 }
 public function validateAttribute($object, $attribute)
 {
     $value = $object->{$attribute};
     if ($this->allowEmpty && ($value === null || $value === '')) {
         return;
     }
     $criteria = new EMongoCriteria();
     if (!$object->getIsNewRecord()) {
         $criteria->addCond('_id', '!=', $object->getPrimaryKey());
     }
     $criteria->addCond($attribute, '==', $value);
     $count = $object->model()->count($criteria);
     if ($count !== 0) {
         $this->addError($object, $attribute, Yii::t('yii', '{attribute} is not unique in DB.'));
     }
 }
Example #4
0
 public static function getByBiobank($biobankId, $limit)
 {
     $criteria = new EMongoCriteria();
     $criteria->addCond('biobank_id', '==', $biobankId);
     $criteria->sort('date', EMongoCriteria::SORT_DESC);
     $criteria->limit($limit);
     return BiobankStats::model()->findAll($criteria);
 }
Example #5
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search($options = array())
 {
     $criteria = new EMongoCriteria();
     if (isset($this->old_value) && !empty($this->old_value)) {
         $criteria->addCond('old_value', '==', new MongoRegex('/' . $this->old_value . '/i'));
     }
     if (isset($this->new_value) && !empty($this->new_value)) {
         $criteria->addCond('new_value', '==', new MongoRegex('/' . $this->new_value . '/i'));
     }
     if (isset($this->action) && !empty($this->action)) {
         $criteria->addCond('action', '==', new MongoRegex('/' . $this->action . '/i'));
     }
     if (isset($this->model) && !empty($this->model)) {
         $criteria->addCond('model', '==', new MongoRegex('/' . $this->model . '/i'));
     }
     if (isset($this->field) && !empty($this->field)) {
         $criteria->addCond('field', '==', new MongoRegex('/' . $this->field . '/i'));
     }
     if (isset($this->stamp) && !empty($this->stamp)) {
         $criteria->stamp = array('$gte' => $this->stamp, '$lte' => $this->stamp);
     }
     return new EMongoDocumentDataProvider($this, array('criteria' => $criteria));
 }
 public function search($caseSensitive = false)
 {
     $criteria = new EMongoCriteria();
     if (isset($this->title) && !empty($this->title)) {
         $regex = '/';
         foreach ($this->title as $value) {
             $regex .= $value;
             if ($value != end($this->title)) {
                 $regex .= '|';
             }
         }
         $regex .= '/i';
         $criteria->addCond('title', '==', new MongoRegex($regex));
     }
     Yii::app()->session['criteria'] = $criteria;
     return new EMongoDocumentDataProvider($this, array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'title ASC')));
 }
Example #7
0
 public function searchFilter($caseSensitive = false)
 {
     $criteria = new EMongoCriteria();
     if (isset($_SESSION['id_patient'])) {
         $criteria->id_patient = new MongoRegex($_SESSION['id_patient']);
     }
     if (isset($this->dynamics) && !empty($this->dynamics)) {
         $index = 0;
         $nbCriteria = array();
         foreach ($this->dynamics as $questionId => $answerValue) {
             if ($answerValue != null && !empty($answerValue)) {
                 if ($index != 0) {
                     $nbCriteria = '$criteria' . $index;
                     $nbCriteria = new EMongoCriteria();
                 }
                 if (isset($this->compare[$questionId])) {
                     if ($index == 0) {
                         if ($this->compare[$questionId] == "between") {
                             $answerDate = $this->formatDatePicker($answerValue);
                             $criteria->addCond('answers_group.answers', 'elemmatch', array('id' => $questionId, 'answer.date' => array('$gte' => $answerDate['date_from'] . " 00:00:00.000000", '$lte' => $answerDate['date_to'] . " 23:59:59.000000")));
                         } else {
                             $criteria->addCond('answers_group.answers', 'elemmatch', array('id' => $questionId, 'answer' => array(EMongoCriteria::$operators[$this->compare[$questionId]] => (int) $answerValue)));
                         }
                     } else {
                         if ($this->compare[$questionId] == "between") {
                             $answerDate = $this->formatDatePicker($answerValue);
                             $nbCriteria->addCond('answers_group.answers', 'elemmatch', array('id' => $questionId, 'answer.date' => array('$gte' => $answerDate['date_from'] . " 00:00:00.000000", '$lte' => $answerDate['date_to'] . " 23:59:59.000000")));
                         } else {
                             $nbCriteria->addCond('answers_group.answers', 'elemmatch', array('id' => $questionId, 'answer' => array(EMongoCriteria::$operators[$this->compare[$questionId]] => (int) $answerValue)));
                         }
                     }
                 } else {
                     $values = !is_array($answerValue) ? split(',', $answerValue) : $answerValue;
                     if ($index == 0) {
                         $criteria->addCond('answers_group.answers', 'elemmatch', array('id' => $questionId, 'answer' => new MongoRegex($this->regexString($values))));
                     } else {
                         $nbCriteria->addCond('answers_group.answers', 'elemmatch', array('id' => $questionId, 'answer' => new MongoRegex($this->regexString($values))));
                     }
                 }
             }
             if ($index != 0) {
                 $criteria->mergeWith($nbCriteria, $this->condition[$questionId]);
             }
             $index++;
         }
     }
     $criteria->sort('id_patient', EMongoCriteria::SORT_ASC);
     $criteria->sort('type', EMongoCriteria::SORT_ASC);
     $criteria->sort('last_updated', EMongoCriteria::SORT_DESC);
     Yii::app()->session['criteria'] = $criteria;
     return new EMongoDocumentDataProvider($this, array('criteria' => $criteria));
 }
Example #8
0
 /**
  * affichage de la page de recherche des echantillons
  */
 public function actionSearch()
 {
     $model = new Sample('search');
     $model->unsetAttributes();
     $biobankId = null;
     if (isset($_GET['id']) && isset($_GET['layout']) && $_GET['layout'] == 'vitrine_layout') {
         $biobankId = $_GET['id'];
     }
     $model->biobank_id = $biobankId;
     $user = CommonTools::getConnectedUser();
     if (isset($_GET['Preferences'])) {
         $user->preferences->attributes = $_GET['Preferences'];
         $user->disableBehavior('LoggableBehavior');
         if ($user->validate(array('preferences'))) {
             $user->save(false);
         } else {
             var_dump($user->preferences->errors);
         }
     }
     if (isset($_GET['Sample'])) {
         $model->attributes = $_GET['Sample'];
         //Used to search terms in model->biobank->collection_id and model->biobank->collection_name
         $arrayOfBiobanks = array();
         if (!empty($_GET['collection_id'])) {
             $criteria = new EMongoCriteria();
             $listWords = explode(",", $_GET['collection_id']);
             $regexId = "";
             foreach ($listWords as $word) {
                 $regexId .= "{$word}|";
             }
             $regexId = substr($regexId, 0, -1);
             $criteria->addCond('collection_id', '==', new MongoRegex("/({$regexId})/i"));
             $criteria->select(array('_id'));
             $biobanks = Biobank::model()->findAll($criteria);
             foreach ($biobanks as $biobank) {
                 $arrayOfBiobanks[(string) $biobank->_id] = (string) $biobank->_id;
             }
         }
         if (!empty($_GET['collection_name'])) {
             $criteria = new EMongoCriteria();
             $listWords = explode(",", $_GET['collection_name']);
             $regexId = "";
             foreach ($listWords as $word) {
                 $regexId .= "{$word}|";
             }
             $regexId = substr($regexId, 0, -1);
             $criteria->addCond('collection_name', '==', new MongoRegex("/({$regexId})/i"));
             $criteria->select(array('_id'));
             $biobanks = Biobank::model()->findAll($criteria);
             foreach ($biobanks as $biobank) {
                 $arrayOfBiobanks[$biobank->_id] = (string) $biobank->_id;
             }
         }
         if (!empty($arrayOfBiobanks)) {
             //     $model->arrayOfBiobanks;
             $model->setArrayOfBiobanks(array_values($arrayOfBiobanks));
         }
         $content = '';
         foreach ($_GET['Sample'] as $key => $value) {
             if (is_array($value)) {
                 foreach ($value as $vkey => $vval) {
                     $content = $content . (string) $vkey . '=' . str_replace(';', ',', (string) $vval) . ';';
                 }
             } else {
                 if ($value != null && !empty($value) && (string) $value != '0') {
                     $content = $content . (string) $key . '=' . str_replace(';', ',', (string) $value) . ';';
                 }
             }
         }
         if (Yii::app()->session['SampleForm'] != $_GET['Sample']) {
             $_GET['Echantillon_page'] = null;
             $this->logAdvancedSearch($content);
         }
         Yii::app()->session['SampleForm'] = $_GET['Sample'];
     }
     //form de la recherche intelligente
     $smartForm = new SampleSmartForm();
     if (isset($_POST['SampleSmartForm'])) {
         $model->unsetAttributes();
         $smartForm->attributes = $_POST['SampleSmartForm'];
         if (Yii::app()->session['keywords'] != $smartForm->keywords) {
             $_GET['Echantillon_page'] = null;
             $this->logSmartSearch($smartForm->keywords);
         }
         Yii::app()->session['keywords'] = $smartForm->keywords;
         $model = SmartResearcherTool::search($smartForm->keywords, $biobankId);
     }
     $this->render('search_samples', array('model' => $model, 'smartForm' => $smartForm));
 }
Example #9
0
 /**
  * Recupere les dernieres statistiques de chaque buiobanque, et calcule les statisqtiues globales
  * @return type
  */
 public function getAverageRate()
 {
     $result = array();
     $listAttributes = StatTools::getAttributesForRating();
     $bbStatsCriteria = new EMongoCriteria();
     $bbStatsCriteria->addCond('biobank_id', '!=', '0');
     // $biobanksStats = BiobankStats::model()->findAll($bbStatsCriteria);
     $biobanksStats = array();
     $collAggregate = BiobankStats::model()->getCollection()->aggregate(array('$sort' => array('date' => -1)), array('$group' => array('_id' => '$biobank_id', 'biobank' => array('$first' => array('values' => '$values', 'date' => '$date')))));
     foreach ($collAggregate['result'] as $firstResult) {
         $stats = new BiobankStats();
         $stats->setAttributes($firstResult['biobank'], false);
         $biobanksStats[] = $stats;
     }
     $rateCount = 0;
     foreach ($listAttributes as $attributeName => $attributeConstraint) {
         $partialResult = 0;
         foreach ($biobanksStats as $BiobankStats) {
             if (isset($BiobankStats->values[$attributeName])) {
                 $partialResult += $BiobankStats->values[$attributeName];
             }
         }
         $result['values'][$attributeName] = $partialResult / count($biobanksStats);
         $rateCount += $result['values'][$attributeName];
     }
     $result['globalRate'] = $rateCount / count($listAttributes);
     return $result;
 }
Example #10
0
 public function getSamplesFromArray($samples)
 {
     $criteria = new EMongoCriteria();
     $criteria->addCond('_id', 'in', $samples);
     return new EMongoDocumentDataProvider($this, array('criteria' => $criteria));
 }
Example #11
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search($caseSensitive = false)
 {
     $criteria = new EMongoCriteria();
     if ($this->first_name != null) {
         $criteria->addCond('first_name', '==', new MongoRegex('/' . $this->first_name . '*/i'));
     }
     if ($this->last_name != null) {
         $criteria->addCond('last_name', '==', new MongoRegex('/' . $this->last_name . '*/i'));
     }
     if ($this->ville != null) {
         $criteria->addCond('ville', '==', new MongoRegex('/' . $this->ville . '*/i'));
     }
     if ($this->pays != null) {
         $criteria->addCond('pays', '==', new MongoRegex('/' . $this->pays . '*/i'));
     }
     if ($this->inactive != null) {
         $criteria->addCond('inactive', '==', $this->inactive);
     }
     //always sort with alphabetical order
     $criteria->sort('last_name', EMongoCriteria::SORT_ASC);
     Yii::app()->session['criteria'] = $criteria;
     return new EMongoDocumentDataProvider($this, array('criteria' => $criteria));
 }
Example #12
0
 /**
  * 获取内容列表
  * http://db.admin.mofang.com/api/card/getitems?setid=1&select=name
  */
 public function actionGetItems()
 {
     $return = array('code' => 0, 'data' => array(), 'pages' => array(), 'show_type' => 1);
     //参数接收
     //http://db.dev.mofang.com/api/card/getitems/setid/4/filter/djfl|珍品::/regex/djname|水/order/xyd|1/page/-2/size/20
     $datasetId = isset($_GET['setid']) ? intval($_GET['setid']) : 0;
     //表id			setid = 4
     $select = isset($_GET['select']) ? $_GET['select'] : '';
     //返回字段		select = data.name
     $filter = isset($_GET['filter']) ? $this->paramStr2Arr($_GET['filter']) : '';
     //过滤条件		filter = djfl|珍品::	m_power|[20,1000](多个且关系)[m_power]魔力在20-1000范围内
     $regex = isset($_GET['regex']) ? $this->paramStr2Arr($_GET['regex']) : '';
     //正则匹配		regex = djname|碎片(目前是不限定头尾匹配,后面需要优化)
     $order = isset($_GET['order']) ? $this->paramStr2Arr($_GET['order']) : '';
     //排序			order = xyd|1
     $currPage = isset($_GET['page']) && $_GET['page'] >= 1 ? intval($_GET['page']) : 1;
     //当前页码		page = 1
     $pageSize = isset($_GET['size']) ? intval($_GET['size']) : 0;
     //每页数量		size = 20
     //参数验证
     if (empty($datasetId)) {
         $return['code'] = -9101;
         //接口参数不足
     }
     $cache_data = null;
     $this->checkCache($cache_data);
     //检查缓存
     if (!empty($cache_data)) {
         echo $cache_data;
         return;
     }
     //开始查询
     if (empty($return['code'])) {
         $dsModel = $this->loadModel($datasetId, 'ds');
         $fields = array_keys($dsModel->fields);
         //查询器
         $criteria = new EMongoCriteria();
         $criteria->addCond('dataset_id', '==', $datasetId);
         //指明对象
         if ($select) {
             $select = explode(',', $select);
             foreach ($select as $skey => $sfield) {
                 $select[$skey] = 'data.' . $sfield;
             }
             array_unshift($select, 'id');
             //压入默认字段
             $criteria->select($select);
         }
         //加入过滤条件
         if ($filter) {
             foreach ($filter as $fkey => $fval) {
                 //特殊处理20:1000 数据
                 if (preg_match("/\\d+:\\d+/", $fval)) {
                     $_numberfield = explode(':', $fval);
                     $_minval = intval($_numberfield[0]);
                     $_maxval = intval($_numberfield[1]);
                     // ==
                     if ($_minval == $_maxval) {
                         $criteria->addCond('data.' . $fkey, '==', $_minval);
                         continue;
                     }
                     !empty($_minval) && $criteria->addCond('data.' . $fkey, '>=', $_minval);
                     if ($_minval <= $_maxval) {
                         !empty($_maxval) && $criteria->addCond('data.' . $fkey, '<=', $_maxval);
                     }
                     continue;
                 }
                 if (in_array($fkey, $fields)) {
                     //只查询定义的字段
                     $criteria->addCond('data.' . $fkey, '==', $fval);
                 } else {
                     if (in_array($fkey, array('id'))) {
                         $criteria->addCond($fkey, '==', intval($fval));
                     }
                 }
             }
         }
         //加入正则
         if ($regex) {
             foreach ($regex as $rkey => $rval) {
                 if (in_array($rkey, $fields)) {
                     //只查询定义的字段
                     $rkey = 'data.' . $rkey;
                     $criteria->{$rkey} = new MongoRegex('/' . $rval . '/i');
                 }
             }
         }
         //排序
         if ($order) {
             foreach ($order as $okey => $oval) {
                 if (in_array($okey, $fields)) {
                     //只查询定义的字段
                     $criteria->sort('data.' . $okey, $oval);
                 }
             }
         } else {
             $criteria->sort('id', EMongoCriteria::SORT_ASC);
             //默认id正序
         }
         //构建分页
         $count = CardItem::model()->count($criteria);
         $pages = new CPagination($count);
         $pages->pageSize = $pageSize;
         $offset = ($currPage - 1) * $pageSize;
         $criteria->limit($pageSize)->offset($offset);
         //查询本页
         $return['data'] = CardItem::model()->findAll($criteria);
         //数据显示方式
         $return['show_type'] = $dsModel->show_type;
         $return['pages'] = array('itemCount' => $count, 'pageSize' => $pageSize, 'currPage' => $currPage);
         foreach ($return['data'] as $rkey => $rval) {
             $arr_info = $return['data'][$rkey]->toArray();
             //清除无用的字段
             unset($arr_info['dataset_id']);
             unset($arr_info['request_times']);
             unset($arr_info['last_uid']);
             unset($arr_info['update_time']);
             unset($arr_info['_id']);
             $return['data'][$rkey] = $arr_info;
         }
         $this->writeCache(CJSON::encode($return));
         //设置缓存
     }
     echo CJSON::encode($return);
 }
Example #13
0
 /**
  * Support mongo models interface.
  *
  * @param \EMongoDocument $model
  * @param string|array $where
  * @throws ApiException, NotFoundApiException
  */
 private function mongoGet($model, $where = null)
 {
     $criteria = new \EMongoCriteria();
     if ($id = \Yii::app()->request->getParam(self::ID, false)) {
         $this->data = $model->findByPk($id);
     } else {
         if ($ids = \Yii::app()->request->getParam(self::IDS, false)) {
             // something
         } else {
             $params = $this->getPaginationParams();
             $criteria->offset($params['offset']);
             $criteria->limit($params['limit']);
             if ($order = \Yii::app()->request->getParam(self::ORDER, false)) {
                 $params = explode(' ', $order);
                 $criteria->sort($params[0], $params[1] == 'desc' ? \EMongoCriteria::SORT_DESC : \EMongoCriteria::SORT_ASC);
             }
             if ($where) {
                 if (is_array($where)) {
                     foreach ($where as $cond) {
                         $params = explode(' ', $cond);
                         if ($params[1] == 'in') {
                             $params[2] = $this->manageInCondition($params[2]);
                         }
                         $criteria->addCond($params[0], $params[1], is_numeric($params[2]) ? (int) $params[2] : $params[2]);
                     }
                 } else {
                     $params = explode(' ', $where);
                     if ($params[1] == 'in') {
                         $params[2] = $this->manageInCondition($params[2]);
                     }
                     $criteria->addCond($params[0], $params[1], is_numeric($params[2]) ? (int) $params[2] : $params[2]);
                 }
             }
             $this->data = $model->findAll($criteria);
             if ($this->data == null) {
                 throw new NotFoundApiException();
             }
         }
     }
 }
Example #14
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function search($caseSensitive = false)
 {
     // Warning: Please modify the following code to remove attributes that
     // should not be searched.
     $criteria = new EMongoCriteria();
     if ($this->identifier != null) {
         $criteria->addCond('identifier', '==', new MongoRegex('/' . $this->identifier . '/i'));
     }
     if ($this->name != null) {
         $criteria->addCond('name', '==', new MongoRegex('/' . $this->name . '/i'));
     }
     if ($this->collection_name != null && $this->collection_name != "") {
         $listWords = explode(" ", $this->collection_name);
         $regex = "";
         foreach ($listWords as $word) {
             $regex .= "{$word}|";
         }
         $regex = substr($regex, 0, -1);
         $criteria->addCond('collection_name', '==', new MongoRegex("/({$regex})/i"));
     }
     if ($this->collection_id != null && $this->collection_id != "") {
         $listWords = explode(" ", $this->collection_id);
         $regexId = "";
         foreach ($listWords as $word) {
             $regexId .= "{$word}|";
         }
         $regexId = substr($regexId, 0, -1);
         $criteria->addCond('collection_id', '==', new MongoRegex("/({$regexId})/i"));
     }
     if ($this->diagnosis_available != null && $this->diagnosis_available != "") {
         $listWords = explode(" ", $this->diagnosis_available);
         $regexId = "";
         foreach ($listWords as $word) {
             $regexId .= "{$word}|";
         }
         $regexId = substr($regexId, 0, -1);
         $criteria->addCond('diagnosis_available', '==', new MongoRegex("/({$regexId})/i"));
     }
     if ($this->keywords_MeSH != null && $this->keywords_MeSH != "") {
         $listWords = explode(" ", $this->keywords_MeSH);
         $regexId = "";
         foreach ($listWords as $word) {
             $regexId .= "{$word}|";
         }
         $regexId = substr($regexId, 0, -1);
         $criteria->addCond('keywords_MeSH', '==', new MongoRegex("/({$regexId})/i"));
     }
     if ($this->contact_id != null && $this->contact_id != "") {
         $criteria->contact_id = $this->contact_id;
     }
     if (isset($this->address) && $this->address->city != null) {
         $criteria->addCond('address.city', '==', new MongoRegex('/' . $this->address->city . '/i'));
     }
     //always sort with alphabetical order on name
     $criteria->sort('name', EMongoCriteria::SORT_ASC);
     Yii::app()->session['criteria'] = $criteria;
     return new EMongoDocumentDataProvider($this, array('criteria' => $criteria));
 }
Example #15
0
 public function search($caseSensitive = false)
 {
     $criteria = new EMongoCriteria();
     if (isset($this->login) && !empty($this->login)) {
         $regex = '/';
         foreach ($this->login as $value) {
             $regex .= $value;
             if ($value != end($this->login)) {
                 $regex .= '|';
             }
         }
         $regex .= '/i';
         $criteria->addCond('login', '==', new MongoRegex($regex));
     }
     if (isset($this->profil) && !empty($this->profil)) {
         $regex = '/';
         foreach ($this->profil as $value) {
             $regex .= $value;
             if ($value != end($this->profil)) {
                 $regex .= '|';
             }
         }
         $regex .= '/i';
         $criteria->addCond('profil', '==', new MongoRegex($regex));
     }
     if (isset($this->nom) && !empty($this->nom)) {
         $regex = '/';
         foreach ($this->nom as $value) {
             $regex .= $value;
             if ($value != end($this->nom)) {
                 $regex .= '|';
             }
         }
         $regex .= '/i';
         $criteria->addCond('nom', '==', new MongoRegex($regex));
     }
     if (isset($this->prenom) && !empty($this->prenom)) {
         $regex = '/';
         foreach ($this->prenom as $value) {
             $regex .= $value;
             if ($value != end($this->prenom)) {
                 $regex .= '|';
             }
         }
         $regex .= '/i';
         $criteria->addCond('prenom', '==', new MongoRegex($regex));
     }
     if (isset($this->email) && !empty($this->email)) {
         $regex = '/';
         foreach ($this->email as $value) {
             $regex .= $value;
             if ($value != end($this->email)) {
                 $regex .= '|';
             }
         }
         $regex .= '/i';
         $criteria->addCond('email', '==', new MongoRegex($regex));
     }
     Yii::app()->session['criteria'] = $criteria;
     return new EMongoDocumentDataProvider($this, array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'login ASC')));
 }
 public function actionResultSearch()
 {
     $idPatient = array();
     $model = new Answer('search');
     $model->unsetAttributes();
     if (isset($_GET['Answer'])) {
         $model->attributes = $_GET['Answer'];
     }
     if (isset($_POST['Answer_id_patient'])) {
         $criteria = new EMongoCriteria();
         $regex = '/^';
         foreach ($_POST['Answer_id_patient'] as $idPatient) {
             $regex .= $idPatient . '$|^';
         }
         $regex .= '$/i';
         $criteria->addCond('id_patient', '==', new MongoRegex($regex));
         $_SESSION['id_patient'] = $regex;
     }
     $this->render('result_search', array('model' => $model));
 }
Example #17
0
 /**
  * 批量清理指定天数之前的备份
  * @param $days		int		有效期的天数,默认30(之前的都会被清理掉)
  * @return 清理结果 true
  */
 protected function cleanFile($days = 30)
 {
     $criteria = new EMongoCriteria();
     $criteria->addCond('metadata.addTime', '<', time() - $days * 24 * 3600);
     //指明对象
     return File::model()->deleteAll($criteria);
 }
Example #18
0
 /**
  * 获取表查询的范围条件
  * @return unknown_type
  */
 public function getScopeDsCriteria()
 {
     $criteria = new EMongoCriteria();
     if ($this->get_login_user('scopeInfo', 'ds') != 'all') {
         $criteria->addCond('id', 'in', $this->get_login_user('scopeInfo', 'ds'));
     }
     $criteria->sort('id', EMongoCriteria::SORT_ASC);
     return $criteria;
 }