M
M
magary42016-09-17 14:04:20
symfony
magary4, 2016-09-17 14:04:20

Is there any sense in the ORM for my case?

Is there a threshold when using an ORM becomes unjustified/justified? Where is he?
I have a module in my application that works with the Solr database. The structure is pretty simple. Each document contains about 30 fields. Each document can have a parent field in which the parent-id is stored, then the grandparent-id, then the great-grandparent, and so on.
Those. sometimes only one document is obtained, and in another case, all the ancestors.
The data in the database is imported through the terminal and never changes. Those. the application works with the database in read-only mode
At the moment it works like this:
$doc->title= $result[title]
$doc->inStock= $result[in_stock]
Etc. Sometimes some additional transformation.
Does ORM make sense?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2016-09-17
@magary4

Is there a threshold when using an ORM becomes unjustified/justified? Where is he?

ORMs are needed for one specific type of system - OLTP (On-line Transaction Processing)
You have documents, document databases don't have relationships. That's why you need an Object Document Manager and not an Object Relational Mapper.
Here I have doubts, because these are connections, and connections are not ok. Especially since sometimes you need to pick up more than one document.
Then you definitely don't need ORM/ODM.
But this is a transformation at the level of formation of the result of the sample, right? If so, then again, this is not the problem.

I
index0h, 2016-09-17
@index0h

Is there a threshold when using an ORM becomes unjustified/justified? Where is he?

Most often, it becomes unjustified due to too high overhead costs.
Example:
User MANY_TO_MANY Group
User MANY_TO_MANY Category
We need to find all categories given a list of user groups. In the case of Doctrine ORM, you will have to load the list of groups, then loop through all users (if the load is lazy - it's a bunch of requests), then go through all users and pull out all categories, plus remove duplicates. Plain sql is better here, or query builder, whichever you prefer.
In the case when the overhead is not high AND ORM will be more convenient - you should use ORM. For example: you already have a loaded user, you want to get all his groups. In case of Doctrine ORM it might look like: $user->getGroups().

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question