views:

1243

answers:

4

Hi,

There are two things that seem to be popular nowadays and I was wondering what are the pros and cons of using something like this: http://codeigniter.com/user_guide/database/active_record.html ?

Another thing is ORM (Doctrine for instance). What are the benefits of using these?

+2  A: 

You can take a look at these questions though they're not exactly PHP specific:

KahWee Teng
+5  A: 

ActiveRecord is a pattern common in ORMs. Doctrine is an ORM which uses an ActiveRecord'ish style.

Some benefits of using tools like Doctrine:

  • Database independence: The code should be easy to port to different DBs. For example, I often test using SQLite and use MySQL or Postgre in production with no changes in code.
  • They reduce the amount of code you have to write: A large part of application code deals with communicating with the database. An ORM takes care of most of that, so you can concentrate on writing the actual app.

Of course, they don't come without disadvantages:

  • Doctrine is heavy so it is slower than using straight SQL
  • ORMs can be complex, adding some weight to what you have to learn, and they can sometimes be difficult to understand for inexperienced programmers
Jani Hartikainen
+1  A: 

I tried to keep it light-weight and understandable. Even comes with it's own Mootools based Class Generator :)

http://www.schizofreend.nl/Pork.dbObject/

check it out :)

SchizoDuckie
A: 

I'll try this library :)

Thank you for share this.

eaguilar