Example #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($additionalCriteria = null)
 {
     // @todo Please modify the following code to remove attributes that should not be searched.
     $criteria = new CDbCriteria();
     // $criteria->with=array('userization'=>array('together'=>true));
     if ($additionalCriteria !== null) {
         $criteria->mergeWith($additionalCriteria);
     }
     if ($this->id) {
         $this->id = (int) $this->id;
     }
     $criteria->compare('t.id', $this->id);
     $criteria->compare('LOWER(t.title)', MHelper::String()->toLower($this->title), true);
     $criteria->compare('t.description', $this->description, true);
     $criteria->compare('t.lft', $this->lft);
     $criteria->compare('t.rgt', $this->rgt);
     $criteria->compare('t.status_id', $this->status_id);
     $criteria->compare('t.level', $this->level);
     $criteria->compare('t.url', $this->url, true);
     $criteria->compare('t.icon', $this->icon, true);
     $criteria->compare('LOWER(t.keywords)', MHelper::String()->toLower($this->keywords), true);
     return new CActiveDataProvider($this, array('criteria' => $criteria, 'sort' => Category::getCSort(), 'pagination' => array('pageSize' => 50)));
 }
Example #2
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($additionalCriteria = null) {
        // @todo Please modify the following code to remove attributes that should not be searched.

        $criteria = new CDbCriteria;

        if($additionalCriteria !== null)
            $criteria->mergeWith($additionalCriteria);

        if($this->id)
            $this->id = (int)$this->id;
        $criteria->compare('t.id', $this->id);
        $criteria->compare('LOWER(t.title)',MHelper::String()->toLower($this->title),true);
        $criteria->compare('t.lft', $this->lft);
        $criteria->compare('t.rgt', $this->rgt);
        $criteria->compare('t.created_date', $this->created_date, true);
        $criteria->compare('t.level',$this->level);
        $criteria->compare('t.url',$this->url,true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
            'sort'       => Category::getCSort(),
            'pagination' => array(
                'pageSize' => 30,
            ),
        ));
    }