开发者

Many-To-Many with additional parameters

开发者 https://www.devze.com 2023-03-30 21:23 出处:网络
using the default entity creation commands: php app/console doctrine:mapping:import testSiteBundle yml

using the default entity creation commands:

php app/console doctrine:mapping:import testSiteBundle yml
php app/console doctrine:generate:entities test --path=src/

C开发者_如何学Goan i make additional parameters in many-to-many relation table work with symfony2+doctrine2 ?

Example case:

Table Invoice
  - invoice id
Table Product
  - product id
Relation-Table InvoiceProduct
  - invoice id
  - product id
  - product quantity

Doctrine by default don't create relation-tables entities, and trying the example above, the "product quantity" is ignored.

what can i do to manage this?


In doctrine, that's not a Many-To-Many relation. It's two OneToMany-Relations with an Entity in the middle

Entity:Invoice - ManyToOne - Entity:InvoiceProduct - OneToMany - Entity:Product

Your additional attributes are just normal fields of the InvoiceProduct-Entity.

0

精彩评论

暂无评论...
验证码 换一张
取 消