我有这样的东西
$model=UserCategory::model()->findAll(array('with'=>array('user.department','totalCount'=>array('condition'=>"user.department.name='Science'"))));
但它说 Unknown column 'user.department.name' 我知道它为什么这么说但是我将如何实现它
我有以下关系
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'),
简而言之,我想找到属于科学系的每个类别下的用户总数