I recently start studying ORM, a question jumped to my mind:
PHP applications use mostly MySql and Sqlite, almost all PHP servers have that installed, so is it worth to use ORM in PHP to be database-indipendent?
What about performance?
Using an ORM will remove dependencies from your code on a particular SQL dialect. Instead of directly interacting with the database you'll be interacting with an abstraction layer that provides insulation between your code and the database implementation.
You should try both using ORM and working without ORM with plain SQL. You will see that 99% [1] of time you are better off with ORM. There are very few projects which are so simple that using ORM is not beneficial.
database independence is not the main reason for using an ORM. what you want to have is a general abstraction of the database. this might imply: simplicity of use, faster development, database independence, ... in any case, usually it's worth using an ORM. if your application sucks up all your cpu power, then you might use some plain sql to optimize certain queries. I guess this is a rare case, though.
you might want to read this: What are the advantages of using an ORM?
There are several reasons you might choose to use an ORM, a few I can think of:
Most of the reasons for using an ORM relate to speed/ease of development.
In terms of performance, I've used doctrine with php before and hydration created a huge overhead compared to just fetching the rows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With