Hi all, I tried a lot on google to find some example that simplify the many-many relation, but I could not find exact answer.
So for my and others understanding, I’ll consider posts and categories example:
Three tables:
1- categories(cat_id, cat_name)
2- posts(post_id, post_name, post_content)
3- posts_categs(cat_id, post_id)
Now, I have created CRUD for both Categories and Posts table. GII generated forms for both Categories and Posts models.
At this point, saving Post and Category works fine but how do I implement the third table. I have specified many-many relations:
In category model:
'posts' => array(self::MANY_MANY, 'Posts', 'posts_categs(cat_id, post_id)'),
In posts model:
'categories' => array(self::MANY_MANY, 'Categories', 'posts_categs(cat_id, post_id)'),
What do I do to save their association? If you could give me some example or url, that would be great.
Thanks