4
I have the following tables:
+----------+ +----------------------+ +------------+
| Produtos | | ProdutosVsCategorias | | Categorias |
+----------+ +----------------------+ +------------+
- ID - ID - ID
- TITULO - ID_PRODUTO - TITULO
- ID_CATEGORIA
- The table
Produtos
contains all my products - The table
ProdutosVsCategorias
has a relationship with the tableProdutos
andCategorias
. - The relationship between the tables
Produtos
andProdutosVsCategorias
occurs through the fieldsID
andID_PRODUTO
respectively and is Onetomany. - The relationship between the tables
ProdutosVsCategorias
andCategorias
occurs through the fieldsID_CATEGORIA
andID
respectively 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?