Thanks for the reply. However it’s not really what I hoped for. Problem is that the findByAttributes syntax is quite more complicated and limited for this purpose. I’m affraid I want something which is not possible (yet).
I don’t want to put the account_id condition in the where statement manually. The notation below is much shorter and safer
$u = $this->account->users(array('condition'=>'id=:id','params'=>array(':id'=>$user_id)));
$u = reset($u); // since $u will be an array with zero or one element, test $u for false to see if found
If you really want to use the …ByPk notation, you probably should create your own method in the CActiveRecord class or override the getRelated() method, see the API docs and source for more info.