Doctrine ORM – many to many with additional parameters

Use the default entity creation command:

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

Can I use symfony2 doctrine2 to create additional parameters in a many to many relational table?

Example case:

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

By default, doctrine does not create relational table entities, and product quantity is ignored when trying the above example

What should I do to manage this?

Solution

In theory, this is not a many - to - many relationship This is the relationship between two onetomany entities in the middle

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

Your other properties are just general fields of invoiceproduct entity

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>