Object-relational mappers are a nice way of simplifying data store interactions, by abstracting the data model into a OO class structure. Or put another way, don’t write SQL, write code that is storage agnostic.
my $thing = Thing->new( id => 123 )->load; $thing->foo('bar'); $thing->save; # # the above is mock code # representing something like: # BEGIN TRANSACTION; UPDATE table things SET foo = 'bar' WHERE ID = 123; END TRANSACTION;
I’ve used a couple of different Perl ORMs over the last four years with great joy: DBIx::Class and (mostly) Rose::DB::Object. Now I’m looking for a suitable PHP project for my toolbelt.
Wikipedia has a good starting list.
Some contenders include:
- Xyster
- Looks nice but depends on Zend Framework so a bit heavy. Handles cascading actions on related objects.
- Doctrine
- The most popular (or at least most-mentioned). It has its own special query language (DQL), which is a philosophical turn-off. Isn’t SQL+PHP good enough? But I see the DQL is optional.
- Rocks PHP Library
- Ambitious. The docs make it seem a little like the Rose framework in its goals: an ORM, a Form manager, a web framework. There’s a DB abstraction layer that claims to support many different db flavors. It seems pretty young though.
- Propel
- Mature. But it uses this external XML definition file which just seems crazy. Again, isn’t SQL+PHP enough?
- DABL
- Based on Propel but simpler. No external XML file (+1). Uses same PDO db abstraction layer as Propel.
- LightORM
- I was initially hopeful about this one but it appears abandoned.
- DataMapper
- My co-worker turned me on to this one (thanks Sean!). I really like the looks of it so far and will be spending some quality time testing it out.
Leave a Reply
You must be logged in to post a comment.