Пример #1
0
 /**
  * return the action criteria
  */
 protected function getCriteria()
 {
     $filters = HoleArchiveFilters::model()->findAll();
     $criteria = new CDbCriteria();
     if ($filters) {
         foreach ($filters as $filter) {
             $condArr = array();
             if ($filter->time_to) {
                 $condArr[] = 'DATE_STATUS < ' . (time() - $filter->time_to);
             }
             if ($filter->type_id) {
                 $condArr[] = 'TYPE_ID = ' . $filter->type_id;
             }
             if ($filter->status) {
                 $condArr[] = 'STATE = "' . $filter->status . '"';
             }
             $condStr = implode(' AND ', $condArr);
             $criteria->addCondition($condStr, 'OR');
         }
     } else {
         $criteria->compare('ID', 0);
     }
     $criteria->compare('archive', 0);
     return $criteria;
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = HoleArchiveFilters::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }