I have 3 models as below
class User extends CActiveRecord
{
public function relations()
{
return array(
'posts' => array(self::HAS_MANY, 'Post', 'user_id'),
);
}
}
class Post extends CActiveRecord
{
public function relations()
{
return array(
'tags' => array(self:: MANY_MANY, 'tag', 'post_tag(tag_id, post_id)'),
);
}
}
class Tag extends CActiveRecord
{
public function relations()
{
return array(
'posts' => array(self::MANY_MANY, 'post', 'post_tag(tag_id, post_id)'),
);
}
}
so the models are user <- post <- post_tag -> tag
how to make relation in user model to count all the tags related to the user ?
Thank you