Exemple #1
0
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * Typical usecase:
  * - Initialize the model fields with values from filter form.
  * - Execute this method to get CActiveDataProvider instance which will filter
  * models according to data in model fields.
  * - Pass data provider to CGridView, CListView or any similar widget.
  * @return CActiveDataProvider the data provider that can return the models
  * based on the search/filter conditions.
  */
 public function search()
 {
     $criteria = new CDbCriteria();
     $criteria->compare('name', $this->name, true);
     // Filtre sur le nombre de news associées
     $filterCriteria = ActiveRecordHelper::addFilterOnAggregatedNumericColumn($this, 'countNews', 'news', 'news', 'category_id', '', false);
     $criteria->mergeWith($filterCriteria);
     return new CActiveDataProvider($this, array('criteria' => $criteria));
 }