I have the following tables:
+----------+ +----------------------+ +------------+
| Produtos | | ProdutosVsCategorias | | Categorias |
+----------+ +----------------------+ +------------+
- ID - ID - ID
- TITULO - ID_PRODUTO - TITULO
- ID_CATEGORIA
Produtos
table contains all my products ProdutosVsCategorias
table has a relation to the Produtos
and Categorias
table. Produtos
and ProdutosVsCategorias
tables occurs through the ID
and ID_PRODUTO
fields respectively and is OneToMany. ProdutosVsCategorias
and Categorias
tables occurs through the ID_CATEGORIA
and ID
fields respectively and is ManyToOne. For each table, I created an entity, but I do not know how to do the relationship between entities in Symfony using Doctrine.
When instantiating the Produto
entity, I 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?