A
A
Alexander Vladimirovich2022-03-03 08:30:06
symfony
Alexander Vladimirovich, 2022-03-03 08:30:06

How to bind an additional entity to an existing table?

Greetings!
There is the News entity, the id, name, text fields,
which, as expected, maps to the news table, has crud, a repository, and so on.
How to create a NewsListItem entity, which will have only id, name fields, we do not need our own table in the database for this entity, we need to use the existing news table. This new entity must have its own repository in order to receive the getAll list, which will select only the id, name fields from the table, and map them into the NewsListItem entity
In other words, I need to get another entity from the same table, which differs in the number of fields.
This additional entity will be used to display in the list. It does not need all the fields of the original entity.
It will not need to be saved to the database, only output.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tukreb, 2022-03-03
@tukreb

I don’t know why this is, when you can make a regular ReadModel through a query builder.
BUT since you really want to get around and bind to the ORM, then use the attribute readOnly
https://www.doctrine-project.org/projects/doctrine...
That is, just create the required entity and give it readonly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question