Doctrine 2 : Best way to manage many-to-many associations

后端 未结 1 982
清歌不尽
清歌不尽 2021-01-03 14:52

Doctrine2 ORM have 2 technical ways to handle many-to-many associations :

1/ For a \"simple\" relation between 2 entities, and without additionnal a

相关标签:
1条回答
  • 2021-01-03 15:29

    If you have a good reason to belief that in the near future you will have extra properties on your ManyToMany join table then it's a good idea to make an entity out of precaution. If not then it's better to use the normal ManyToMany relationship. Then when a change is needed you can update your schema along with your code. If you try to follow the Single responsibility principle then you can avoid refactoring large amounts of code.

    0 讨论(0)
提交回复
热议问题