O
O
Optimus2018-02-10 12:11:31
Software design
Optimus, 2018-02-10 12:11:31

Where to store the table name?

The question is purely about the design and architecture of the PHP application. There are options:
1) Do not store the name of the table anywhere and set it in queries, the disadvantages are clear
2) Store the name in a variable in the class, for example private $mysql_table = 'articles';
3) Take the name of the table from the class name, for example mine class ArticlesModel, then 'articles'this is the name of the table. Thus, I will lose the ability to access the database in controllers, because one controller can resolve actions for several similar entities and it will be forced to transfer processing to the model, and this is good, this imposes a strict restriction on the architecture.
But in the latter case, it is not clear how to deal with the situation when there are secondary tables. For example, an article has tags, respectively, AtriclesModelandTagModelbut there is also an intermediate table that implements their relationship and it does not have its own class...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ipokos, 2018-02-10
Pyan @marrk2

This is not an answer, but a question
Tell me, what are the disadvantages? (really don't understand the problem)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question