S
S
s0lar2019-01-10 22:55:58
symfony
s0lar, 2019-01-10 22:55:58

How to bind multiple database tables of the same type to one Entity in Symfony?

For example, I want to store news by year, as there will be a lot of them in a year. And to facilitate the work of the database, I would like to lay them out in tables news2018, news2019, news2020. The main idea is to lay out the data of one entity in different tables and work with them through one repository!
In fact, I need one Entity\News entity, which will be the same for any news2018, news2019, news2020 table. And one Repository\NewsRepository for requests.
In principle, you can create a factory (if I don’t confuse anything) that will create instances of Entity\News2018 entities ..
But will you also need to redo the Repository class ??
Maybe it's possible to make it easier and I'm complicating everything? (really a lot of data to store in one table)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2019-01-10
@Alex_Wells

What for? The database itself will figure out how it is easier for it, the main thing is to arrange the indexes, it will not become easier for it from a dozen tables, and the code will become an unsupported garbage can.
Don't do it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question