Posted by & filed under CodeIgniter, PHP.

So there is this hype that ORMs are theĀ solution to all your Data Access problems. They may not be the total solution but they sure make your Data Access easy.

At a very high level: ORMs help to reduce the Object-Relational impedance mismatch. They allow you to store and retrieve full live objects from a relational database rather a set or rows.

What Does it Give me as a Developer?

For starters it helps you stay DRY. Here, your schema is the boss and your models are automatically generated based on the schema.
ORMs generally handle the marshaling the values of individual columns into the proper types so that you don’t have to manually serialize them.

How will my code differ from the individual SELECT statements that I use now?

Since ORMs usually return individually formed objects, you’ll be able to access related objects using attribute access rather than writing another query for it. You’ll be able able to write queries if necessary, but form most CRUD operations, the code becomes simpler.

What about the DB schema and Model Classes?

Most ORMs come with configuration tools inspect your DB schema and create the DB tables for your. Also, many of them give the option to generate the Getter/Setter methods in the Model Class that help you interact with the objects in the Database.

I’m a PHP developer, What ORM should I use?

Doctrine is probably the best ORM available for PHP. Although there are many others which provide different kind’s of functionality.
Most people consider CodeIgniter’s Active Record as an ORM tool. I am not sure if it actually fits in completely, But it sure does make the development process easier.

We’ll be exploring more about PHP ORM’s in the following code and mostly about how to use Doctrine with CodeIgniter.

Trackbacks/Pingbacks

  1.  Basics of MVC with PHP

Leave a Reply

  • (will not be published)