Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个实体Order和一个实体Product。
应该可以将一种产品多次添加到订单中,但是使用 Doctrine 默认的多对多关系,连接表中只能有一个关系。有没有办法在没有额外实体和两个一对多关系的情况下解决这个问题?
为什么要多次将产品添加到订单中?使用添加到它的 Quantity 列使其成为多对多关系。一个数量为 N 的产品应该满足您的愿望。
不,您需要一个 OrderLine 表。多对多在概念上可以存在,但在关系数据库中则不能。您必须将其分解为两个多对一关系