When to use an ORM framework?

From my personal experience, an ORM framework becomes more useful as the size and complexity of the project increases. If you just have a simple database with say 5 tables and 5-6 queries … setting up an ORM framework may be overkill. I would start considering the use of ORM when:

  • You have 3 or more programmers on a web application.
  • Your database consist of 10+ tables.
  • You have say 10+ queries to make.

ORM frameworks can’t do it all

If you think that using an ORM framework will allow you to forget SQL and never have to look back, think again. Once you jump into the ORM world, you will find that about 80-90% of your queries can be handled by the ORM generated objects. It is inevitable that at some point you will need to drop down and use some SQL or some SQL like query language.

In fact, ORM frameworks often have their own *QL query language that looks a lot like SQL. Doctrine, a popular PHP based ORM framework has DQL (Doctrine Query Language) and the very popular Hibernate (used in the Java and .Net world) has HQL. Going even further, Hybernate allows you to write straight SQL if need be.

Despite the need for a SQL like language in ORM frameworks, they can still be very valuable tools in your PHP work.

ORM Frameworks for PHP programmers

Not an exhaustive list, but here are a few ORM frameworks to consider:

Source: https://www.killerphp.com/articles/what-are-orm-frameworks/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s