views:

120

answers:

2

The framework I'm starting to learn supports 2 ORMs out of the box. I don't think it matters for the purposes of this question to say which 2 ORMs. My question is more general than this. How do you in general decide which ORM to go with? I haven't used an ORM before, but I'm guessing there's a list of must-haves that any decent ORM must have, then there's a list of nice-to-have and so on.

+4  A: 

An ORM is just like any other software package. You'll need to compare multiple things, it's not all about what it can and can't. Let's think about:

  • Features
  • Documentation
  • Development progress
  • Speed
  • How is the code
  • Community
  • Support

Your priorities can be different than mine. Do you require a future-proof production-stable product? Or do you want something more cutting edge?

Cutting edge: latest techniques. The best ORM will do everything you want. If you find such ORM, go with it. If you don't, you'll have to make a choise. To make the choise correct you will have to question yourself what your needs are.
Cutting edge can be: full usage of php 5.3, latest oop design paradigms (what sort of inheritance does it give you), standards, integration with frameworks. Doctrine2 has quite some cutting edge techniques implemented.
+3  A: 

The first question should be whether your application requires an ORM, not what features the ORM provides. If your app needs an ORM, pick the one that suits your application, not the one that is the most feature-packed. If you dont believe in ActiveRecord, you dont pick the ORM that is based on that pattern, regardless of features.

For an overview of object-relational patterns have a look at Fowler's PoEAA:

An ORM implementing most of the object-relational patterns could tentatively be considered decent, but like I said, if you don't need that, you don't need that.

Gordon
So a single ORM can in fact accommodate more than one database design pattern (ActiveRecord and other)?
jblue
@jblue In theory, yes. In practise AR is the dominant pattern ( [though it sucks for ORM](http://kore-nordmann.de/blog/why_active_record_sucks.html) ).
Gordon
You seem very knowledgeable in this area so I'd like to ask you a related question. I asked about using a service layer with MVC here: `http://stackoverflow.com/questions/3744402/is-mvc-service-layer-common-in-zend-or-php` My question to you is: do some db design patters lend themselves more to a Service Layer on top of the Model?
jblue
@jblue If knowing where to look for certain patterns is knowledgable, then I am knowledgable. But I'm really just a coder of code. :) Bill Karwin gave you the best answer to your question already. I dont think there is any particular DB design pattern that goes especially well with Service Layer.
Gordon