D
D
drboboev2018-11-14 10:26:42
symfony
drboboev, 2018-11-14 10:26:42

How to extend the Doctrine entity class?

Good afternoon.
Given:
There is a User entity, I expand it in the bundle by adding a field. I expand the same entity in another bundle, adding n more fields.
Task:
How to add a record to the database now? After all, extension classes are not related to each other, but only to the parent.
I use Single Table Inheritance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2018-11-14
@Maksclub

General data will be stored in the parent table
. That is, you add an entity to the database:
For other entities, everything is the same ... that is, in the users community, the fields are stored with a common id and type, and the Doctrine itself maps everything

Task:
How to add a record to the database now? After all, extension classes are not related to each other, but only to the parent.
That is, the Doctrine will do everything itself - you only need to specify the DiscriminatorColumn (the entities are mapped in it), if the entities from different bundles are called the same - it is worth filing the DiscriminatorMap

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question