samdark / yii2-cookbook

Yii 2.0 Community Cookbook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Best way to deal with junction table and its extra columns

bpbastos opened this issue · comments

Would be nice a recipe about this subject.

What do you want to do with it?

It was a suggestion of recipe to be included in the cookbook. Sorry if I created it in the wrong place.

No, it's correct place. I've asked because I want to understand your use case to get a better recipe.

Nice! It's a common problem, unfortunately I haven't found a good way of dealing with this without being too much complex. I've found a good article: http://future500.nl/articles/2013/09/doctrine-2-how-to-handle-join-tables-with-extra-columns/ maybe someone can migrate it to yii2.

In general, you need to create a model for that junction table and use it via relations.