Pagination count with relational rows

I try to get the count from Table ‘User’ within the joined table AuthAssignment.

Without the Joined Table AuthAssignment I get 9 rows, but with it there are all together 26 rows.

But I can’t get the count of 26 in the pagination where the result is never more than 9.

How can I get it working, the count() counts the joined Items?

And next it should work with seach criteria within both Tables.

I hope, that’s not to much for Yii.

Here the simple pagination Code.

_addSearchConditions() adds addSearchCondition() to $ct.




private function _getUserList()

{

$ct=new CDbCriteria(array(

	'with'=>array('assignment'), 

	'together'=>true, 

	'order'=>'t.username ASC',

	)

);

$ct=$this->_addSearchConditions($ct);

$count=User::model()->with('assignment')->count($ct);

$this->paginate=new CPagination($count);


// results per page

$this->paginate->pageSize=$this->usersPerPage;

$this->paginate->applyLimit($ct);

$this->users=User::model()->findAll($ct);

return $this->users;

}


private function _addSearchConditions($criteria)

{

	$this->_getSearchFields();

	$fields=array(

		't'=>array(

			's1'=>'username'

		),

		'assignment'=>array(

			's2'=>'itemname',

			's3'=>'bizrule',

			's4'=>'data'

		)

	);

	foreach($fields as $table => $columns)

	{

		foreach($columns as $k => $v)

		{

			if($this->searchFields[$k] != $this->defaultSearchFields[$k])

				$criteria->addSearchCondition("$table.$v", $this->searchFields[$k], true, 'AND', 'LIKE');

		}

	}

	return $criteria;

}

I can’t get this working.

The Column User comes from Table User.

The Columns Roles, BizRule and Data are coming from Table AuthAssignments.

The inputfields above are Searchfields.

And it seems to be impossible, to get the matching Itemcont.

Can anybody help me?