I have a situation here
there are two models User,Posts
Now I want to list those posts posted by user whose userType=1
Is this possible by tweaking the relations among User & Posts or by adding any kind of scopes?
The relations which I’ve now
User
'Posts' => array(self::HAS_MANY, 'Post', 'userId'),
Posts
'User' => array(self::BELONGS_TO, 'User', 'userId'),
You can do this with named scopes or with relations. For example you could define your relation like this:
About “Named Scopes” read here:
http://www.yiiframework.com/doc/guide/1.1/en/database.ar#named-scopes