I've something like this
$model=UserCategory::model()->findAll(array('with'=>array('user.department','totalCount'=>array('condition'=>"user.department.name='Science'"))));
but it says Unknown column 'user.department.name' I know why it says so but how will I implement it
I've following relations
UserCategory
'user' => array(self::HAS_MANY, 'UserCategory', 'categoryId'),
'totalCount' => array(self::STAT, 'UserCategory', 'categoryId'),//counts total of user under each category
User
'userCat' => array(self::BELONGS_TO, 'UserCategory', 'categoryId'),
'department' => array(self::BELONGS_TO, 'Department', 'departmentId'),
Department
'userDept' => array(self::HAS_MANY, 'User', 'departmentId'),
In short I want to find total number user under each category who belongs to department science