The way I see it is like this. To use an ORM, you have to usually stack several php functions, and then connect to a database and essentially still run a MySQL query or something similar.
Why all of the abstraction in between code and database? Why can't we just use what we already know? Typically a web dev knows their backend language, their db language (some sort of SQL), and some sort of frontend languages, such as html, css, js, etc...
In essence, we're trying to add a layer of abstraction that includes many functions (and we all know php functions can be slower than assigning a variable). Yes, this is a micro calculation, but still, it adds up.
Not only do we now have several functions to go through, but we also have to learn the way the ORM works, so there's some time wasted there. I thought the whole idea of separation of code was to keep your code separate at all levels. If you're in the LAMP world, just create your query (you should know MySQL) and use the already existing php functionality for prepared statements. DONE!
LAMP WAY:
- create query (string);
- use mysqli prepared statements and retrieve data into array.
ORM WAY:
- run a function that gets the entity
- which runs a MySQL query
- run another function that adds a conditional
- run another function that adds another conditional
- run another function that joins
- run another function that adds conditionals on the join
- run another function that prepares
- runs another MySQL query
- run another function that fetches the data
- runs another MySQL Query
Does anyone else have a problem with the ORM stack? Why are we becoming such lazy developers? Or so creative that we're harming our code? If it ain't broke don't fix it. In turn, fix your dev team to understand the basics of web dev.
SELECT
the object just to update one of its fields, resulting in multiple queries. This is something I am going to address via lazy loading. – Reminiscence