Yii Search Tutorials

CDbCriteria Search

Yii framework model have search() function. We can create more function like search. I created new function ‘searchcategory’ and i added some custom function to searchcategory() function. Example public function searchcategory() { $criteria=new CDbCriteria; $condition=''; $categoryname=$this->categoryname; if($this->categoryname1!='') { $categorystring=$this->likecategoryname($this->categoryname1); if($categorystring!='') { $condition="categoryidIN (".$categorystring.")"; } } if($categoryname!='') { $categoryidstring=$this->likecategoryname($categoryname); if($categoryidstring!='') { if($condition!='') $condition.=' AND '; $condition.="categoryid IN (".$categoryidstring.")"; } } if($condition!='') { $criteria->condition=$condition; } return new CActiveDataProvider($this, array( 'criteria'=>$criteria, )); } […]... Read More »