D
D
Dmitry Dimedrolov2017-08-26 15:34:42
symfony
Dmitry Dimedrolov, 2017-08-26 15:34:42

What if Doctrine Entities have the same structure?

I started to learn Symfony and took one of my old projects as a basis, on which I learned to put graphs in a database, more specifically, MySQL on MyISAM. I translated the tables into InnoDB, set up Foreign Key's - in order to shift integrity control to the base and thus import integrity control along with the schema into Doctrine. I import doctrine:mapping:import schema and... Doctrine swears "cannot redeclare" on one of the foreign key columns. I'm trying the same from the other end, through doctrine annotations in Entity. doctrine:generate:entity -- and again, "cannot redeclare" when I try to join a Location entity that is common to Bridge and Building entities.
Accordingly, the questions are:
1) Do I understand correctly that the Location entity, represented in the database by one table, will have to be split into two entities (and tables): LocationOfBridge and LocationOfBuilding?
2) do you really have to write two identical controllers on entities with the same structure?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2017-08-26
@Austin_Powers

Create a base entity. Inherit your entities from the base one and use Single Table Inheritance to map the entities into a single table.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question