how to search related model attributes with pagination


I am trying to search persons model who has relation with parent

I want to filter the parent relation attributes by using criteria->with

$criteria->condition =  $criteria->condition.' and parent.is_active=:active';

$total = persons::model()->with('parent')->count($criteria);

$pages = new CPagination($total);



$list = persons ::model()->with('parent')->findAll($criteria);


Unknown column ‘parent.is_active’ in ‘where clause’

I understand this is due to the lazy loading not joining with the parent model.

But how to achieve the filter on relation and pagination together in any case lazy or eager loading ?

pls. note iam not using cgridview just html table in the view. but

$this->widget('CLinkPager', array(








Thanks alot

You need to join your data so you can use it. This appears to be Yii1 and it’s been so long since I’ve used it so all I can say is in Yii2 you use joinWith() instead of with(). If you are using SQL it is a left join.