Babas007, on 05 January 2013 - 05:58 AM, said:
That's too bad, is there any other ORM compatible with Yii?
Someone may have some idea, but I don't know.
By the way, how to make a join table with active record to make it unidirectionnal?
I'm sorry, but I don't understand what you mean by that.
Would be nice to write something like this:
class Post extends CActiveRecord
public function relations()
'author'=>array(self::BELONGS_TO, 'User', 'author_id'),
'categories' should be a MANY_MANY relation in Yii's terminology, and it is supported.
'categories'=>array(self::MANY_MANY, 'Category', 'tbl_post_category(post_id, category_id)'),
But Yii doesn't have a method to save/update MANY_MANY relation out of the box. You have to create/delete records in tbl_post_category manually, most probably using PostCategory AR model.
I've heard that Yii 2.0 will be different, but Yii 1.0 and 1.1 don't support the saving of the related models. You have to do it by yourself, or have to use some extension to automate it.
It's so-called by-design. I'm not very sure but it looked to me that the developer(s) avoided a complex (and possibly heavy and fragile) mechanism of saving relations. And personally I believe it was the right decision. Or, should I say, I'm already accustomed to it by now.