Initial thoughts on Doctrine

I started to use Doctrine this year, and I have to say that I think I prefer it over Propel now on how you construct queries. The syntax is a little cleaner as well in my opinion. Here is an example of both syntaxes to retrieve a set of articles from a database which match a few criteria.

Propel:

$criteria = new Criteria('article a');
$criteria->add('a.status', 'active');
$criteria->add('a.type', 'news');
$criteria->addDescendingOrderByColumn('a.id');

Doctrine:

$query = new Doctrine_Query::create()
       ->from('article a')
       ->where('a.status = ?', 'active')
       ->andWhere('a.type = ?', 'news')
       ->addOrderBy('a.id DESC');

I also find the Doctrine way or building the query easier to read compared to the Propel one.

Once I’ve worked with Doctrine some more, and built some more complex queries I’ll add some more thoughts.

Leave a Reply

Your email address will not be published. Required fields are marked *