I just came across Yii and it looks very promising. Now I have three questions about ActiveRecord:
I read somewhere that there is a feature like named_scope in rails but couldn't find it. Can anyone give me a hint?
My second question is: Is there something like Rails Programmer has_many :projects, :through => :assignments in Yii? (If you don’t know what this is: It’s like a many to many associations between Programmer and Project. They are associated through an Assignment)
And my last question: When a User has many Posts and a post belongs to a User, is something like this possible:
$user = User::model()->find(1);
$posts = $user->posts->find('something=:something', array(':something'=>10));
$posts should now contain all Posts that belong to the User with ID=1 and something equals 10.
Thanks for any hints.
Thank you for your nice questions.
named_space: We don't have this concept. The implementation is pretty straightforward, however, since Yii has CDbCriteria, which represents everything needed by a query. And one may set up a mapping between scope names and and criterias. We may consider building this into the core in the near future.
has_many through: While Yii supports many-to-many association, it doesn't support this for the moment. I think it's a good idea that we support this in future.
The query conditions need to be specified in relations(). For on-the-fly query condition like you described, Yii only supports it in an eager approach currently:
We may support it in future for lazy approach.
Thank you for the fast reply.
I think I'm going to switch from CakePHP to Yii sooner or later. The only thing so far I like better in CakePHP is their integrated test suite.