How do I join using CActiveDataProvider


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.


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);


return  new CActiveDataProvider( array(





Thank you