Where do you "load balance" ORM in a PHP MVC application

Problem . Object models created using ORM often need to execute multiple queries to perform a single action. For example, the get action can retrieve information from multiple tables, especially if you have a nested object structure. For complex queries, these queries can add up and your database will start blocking long before this happens if you manually wrote SQL.

Question . Where do you download the ORM balance to reduce the number of queries that need to be completed, and more importantly , why do you choose this approach? Do you have separate models for loading context-sensitive data, or do you indicate what data should be loaded in the controller? Or something else?

+3
source share
3 answers

I recommend using the Domain Model template to provide an interface for data using OO-friendly. In the framework of the persistence implementation in the classes of the domain model, it is advisable to use a combination of ORM and SQL.

, . ActiveRecord. , , , , . ActiveRecord , SQL. , JOIN GROUP BY.

@pestaa , . , : . , , .

- .

+1

ORM - .

, , SQL.

+2

ORM, . , ORM , :

  • , . ORM , ORM ( )
  • . , , / .
  • You have a plan for dividing your reading into records. Either in your model or in the ORM configuration. Especially if reading is your bottleneck, using some kind of replication to create a gang of read-only slaves can be extremely useful. However, if you do not plan it, you can easily create a place for yourself where it is a pain.
0
source

Source: https://habr.com/ru/post/1721933/


All Articles