Database Through Relations

Good evening,

In this page (http://www.yiiframework.com/doc/guide/1.1/en/database.arr#relational-query-with-through) it’s described how to get all comments for all users of a particular group using ‘through’.

How can I do exactly the opposite? That is, get the group of the user who made a particular comment.

So far, I’m not even able to reach ‘role’ table:


'user' => array(self::BELONGS_TO, 'User', 'user_id'),

'roles'=>array(self::HAS_MANY, 'Role', array('id'=>'user_id'), 'through' => 'user') // shouldn't it join User.id to Role.user_id ?

It’s raising the following error: 'Column not found: 1054 Unknown column ‘user.user_id’ in ‘where clause’. And it seems related to the first line, not the second…

Any ideas?

Sincerely,

Apidcloud