4
I have the following tables:
+----------+ +----------------------+ +------------+
| Produtos | | ProdutosVsCategorias | | Categorias |
+----------+ +----------------------+ +------------+
- ID - ID - ID
- TITULO - ID_PRODUTO - TITULO
- ID_CATEGORIA
- The table
Produtoscontains all my products - The table
ProdutosVsCategoriashas a relationship with the tableProdutosandCategorias. - The relationship between the tables
ProdutosandProdutosVsCategoriasoccurs through the fieldsIDandID_PRODUTOrespectively and is Onetomany. - The relationship between the tables
ProdutosVsCategoriasandCategoriasoccurs through the fieldsID_CATEGORIAandIDrespectively and is Manytoone.
For each table, I created an entity, but I don’t know how to make the relationship between the entities in Symfony using Doctrine.
By instantiating the entity Produto, need to know which categories are associated with the product.
When instantiating a category, I also need to know which products are associated with the category.
How to make the relationship between entities using the above example?