views:

253

answers:

5

The quote below has convinced to finally go ORM. In the past I havn't really liked ORM and wrote it off as a stupid way of doing sql. Dealing with hierarchical data in sql is a pain I don't want to deal with.

There's a reason we have these “Object-Relational Mapper” things, and it's because of a problem known as the Object-Relational Impedance Mismatch. Basically, the formal mathematical model for databases used to ensure that they stay intact follows a system of tables with rows and columns and references to other tables, while data structures in most programming languages we use today manipulate data in nested tree-like structures. It's rather like the difference between a spreadsheet and an XML document, or between a ledger and a family tree diagram. - http://zork.net/motd/nick/django/your-favorite-orm-sucks.html

I want something with minimal effort to setup. Most of my project are small so I don't want to spend much time defining models when I only use them for few queries.

I'm using codeigniter as the php framework and MySQL as the database.

A: 

CodeIgniter comes with an ORM called Active Record.

Another one I like and have used on a ton of small applications with and without CI is POG: http://phpobjectgenerator.com

Tyler
[Active Record](http://martinfowler.com/eaaCatalog/activeRecord.html) is not an ORM and [using it like one sucks](http://kore-nordmann.de/blog/why_active_record_sucks.html).
Gordon
CI Active Record is not an ORM, as quoted from their site "CodeIgniter uses a modified version of the Active Record Database Pattern."
Flakron Bytyqi
Active Record is a database abstraction layer. I already use it and it's pathetic at handling anything slightly complex. Really it's yet another way of writing single sql queries.
Keyo
+2  A: 

I would recommend

http://www.doctrine-project.org/, it is very popular so you will have knowledge, and will be able to use it in other framworks.

Centurion
+1  A: 

Here are the ones I use

  1. Doctrine

  2. DataMapper (http://stensi.com/datamapper/)

Flakron Bytyqi
+1  A: 

How about Datamapper Overzealous Edition

I think that the original DataMapper (from stensi) isn't under development anymore. (Someone correct me if I'm wrong) Datamapper Overzealous Edition is easy to get working with Codeigniter.

I'm sure Doctrine works well too, but I'm not sure how easy it is to set up with Codeigniter.

Matthew
+1  A: 

Doctrine is brilliant and very easy to setup and use with CI. There are three ways of integrating it 1) the way described in the CI wiki 2) as a plugin 3) using hooks. I don't like option 1 as it involves messing with CI system files. Option 2 is very easy and what i currently use. Setup is described at www.phpandstuff.com. I've never tried option 3 but it sounds interesting - http://blog.medryx.org/2008/10/04/codeigniter-and-doctrine/

musoNic80
Thanks. I'm reading through the doctrine documentation. There is quite a bit to learn but if I can use this on any framework it will be worth while.
Keyo