How do I join using CActiveDataProvider

Hello,

I want to join two tables.

items has category_id

category has id that relates to items

category has field called class that I need to search on

The resultset should be pageable, 20 per page.

Thanks

You should edit the search function of the model items.

check the doc for CActiveDataProvider, you will notice that there are the property condition, pagination and sort for customization.

All this configuration can be specified as array, something like that:





$condition->compare('class', $this->category_id);


$condition->with=array('category');


return  new CActiveDataProvider( array(

   'condition'=>$condition,

   'pagination'=>array('pageSize'=>20)


)


);



Thank you