Find us on facebook

Aug 2, 2014

CDbCriteria with grid searching ability

$criteria=new CDbCriteria;
$res_id = CF::get_resid();
$criteria->compare('id',$this->id);
$criteria->compare('name',$this->name,true);
$criteria->compare('create_date',$this->create_date,true);
$criteria->compare('res_id',$res_id);
$criteria->compare('is_active',$this->is_active);
$criteria->addSearchCondition('is_active', 1);
$criteria->addSearchCondition('res_id', $res_id);
//condition = "is_active=:is_active AND res_id=:res_id";
//$criteria->params = array(':is_active'=>1,':res_id'=>$res_id);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination'=>array(
                        'pageSize'=>4,
                ),
));

No comments:

Post a Comment