<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tony Bibbs &#187; ORM</title>
	<atom:link href="http://www.tonybibbs.com/tag/orm/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tonybibbs.com</link>
	<description>Family, Outdoors and Technology</description>
	<lastBuildDate>Tue, 17 Aug 2010 15:32:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Comparing Propel and Doctrine</title>
		<link>http://www.tonybibbs.com/2010/02/comparing-propel-and-doctrine/</link>
		<comments>http://www.tonybibbs.com/2010/02/comparing-propel-and-doctrine/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 20:40:18 +0000</pubDate>
		<dc:creator>Tony</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[Propel]]></category>

		<guid isPermaLink="false">http://www.tonybibbs.com/?p=329</guid>
		<description><![CDATA[I&#8217;ve recently decided to make the switch to Doctrine as the ORM of choice for any new PHP projects we work on. I didn&#8217;t make this decision lightly as, until now, I have been a long time user and advocate of Propel having given talks on it at PHP conferences and even a webinar or two. So why the change? That&#8217;s really not significant, what is significant is I think I can give a very quick punchlist of things about each that other PHP&#8217;er might find useful when evaluating them for themselves. Propel Pros &#8211; First, let&#8217;s be clear I&#8217;m not talking about the pros of using an ORM. I&#8217;m talking about the good things that this ORM implementation brings to the table. Those are: Hydration Speed &#8211; You can argue you should never retrieve hydrated PHP objects from query if you don&#8217;t plan on taking some sort of save or delete action on it. Yes, that&#8217;s true from a performance standpoint, however, if you are building a site where performance simply isn&#8217;t a concern then you&#8217;ll be pleased to know Propel can hydrate a set of objects quickly enough to be used in building a view (i.e. a data [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently decided to make the switch to <a href="http://www.doctrine-project.org">Doctrine</a> as the ORM of choice for any new PHP projects we work on.  I didn&#8217;t make this decision lightly as, until now, I have been a long time user and advocate of <a href="http://propel.phpdb.org">Propel</a> having given talks on it at PHP conferences and even a webinar or two.  So why the change?  That&#8217;s really not significant, what is significant is I think I can give a very quick punchlist of things about each that other PHP&#8217;er might find useful when evaluating them for themselves.</p>
<p><b>Propel</b></p>
<p><b>Pros</b> &#8211; First, let&#8217;s be clear I&#8217;m not talking about the pros of using an ORM. I&#8217;m talking about the good things that this ORM implementation brings to the table. Those are:</p>
<ul>
<li>Hydration Speed &#8211; You can argue you should never retrieve hydrated PHP objects from query if you don&#8217;t plan on taking some sort of save or delete action on it.  Yes, that&#8217;s true from a performance standpoint, however, if you are building a site where performance simply isn&#8217;t a concern then you&#8217;ll be pleased to know Propel can hydrate a set of objects quickly enough to be used in building a view (i.e. a data grid of some sort).</li>
<li>Classic Getters/Setters &#8211; You get these methods stubbed out in the base classes that Propel generates and you can override them easily.  I should note Doctrine can do similar sorts of things but not in a conventional way.</li>
<li>Support &#8211; The Propel mailing lists and IRC channel on freenode are pretty active, thought, not near as active as Doctrine&#8217;s.</li>
</ul>
<p><b>Cons</b></p>
<ul>
<li>Dependency hell &#8211; Propel has improved this but it&#8217;s still not perfect.  Back in the early days, before PDO, you needed Propel&#8217;s generator, <a href="http://phing.info">Phing</a> and <a href="http://creole.phpdb.org">Creole</a>.  Now you just need the generator and Phing. Phing is very much like Java&#8217;s Ant build tool.  While I understand and get why they use Phing, it adds a layer of complexity that makes it a barrier to new users.  Propel&#8217;s generator isn&#8217;t as bad as it is just a set of Phing targets to do Propel&#8217;s bidding.  If you come from .NET or Java using Phing won&#8217;t be a big deal but if you aren&#8217;t familiar with Ant or nAnt then Phing will come with a learning curve.</li>
<li>Criteria &#8211; Propel&#8217;s way to help ensure portable queries are built is via their Criteria object.  While I get the need for it, not having a explicit way to run native SQL short of getting a PDO connection and doing all the work that way is a short coming.  In fact, I despise Criteria so much I never use it, mainly because it doesn&#8217;t take too much work to hit a situation that Criteria either can&#8217;t handle well or make the code so complicated it&#8217;s not worth it.</li>
<li>No 5.3 namespace support &#8211; Let&#8217;s face it, we are all tired of Really_Long_Class_Names ala PEAR, Zend Framework, et. al.</li>
<li>Community &#8211; This is probably hard to blame on any one person but for a long time no work was done on Propel.  There was a change in project leads which took a long time and the development efforts took a while to get going.  I&#8217;m happy to say the team is active again, but a lot of ground was lost during the downtime.</li>
</ul>
<p><b>Doctrine</b></p>
<p><b>Pros</b></p>
<ul>
<li>No other dependencies.  Doing builds is easy as creating a simple PHP command line file and running it.  No Phing, no other external property files.</li>
<li>Magic finders &#8211; I love this.  Say you have a user table with a user_name field that has a unique index on it.  Retrieving this is as simple as
<pre>Doctrine::getTable('User')->findOneByUserName('janedoe');</pre>
<p>. Propel would require a few more lines setting up a Criteria object and running it.</li>
<li>Named Queries &#8211; This is something I pitched to the Propel development team quite a long time ago that always got a luke warm reception from the community.  I ended up implementing my own named query implementation which worked well enough that I never used Criteria.  With Doctrine you just get it out of the box:
<pre>
$this->addNamedQuery(
    'someQueryName',
    \Doctrine_Query::create()
        ->select('*')
        ->from('User u')
        ->where(user_name = ? AND 'password = ?')
);
</pre>
<p>Now I&#8217;m not totally in love with that syntax, it&#8217;s not much better than Criteria, honestly, however I go through that pain once and then I can just say:</p>
<pre>
$user = \Doctrine::getTable('User')->find('someQueryName', array('janedoe',SHA1($password)));
</pre>
<p>It&#8217;s also worth noting you can also use named queries to issue raw SQL, though, it will only return the raw recordset. Some of you are probably asking WTF? Named Queries?  Read up on them, decide for yourself if they are for you&#8230;all I can say is after having used an implementation for years I&#8217;m sold on it (maybe that can be a future blog post).
</li>
<li>
Documentation &#8211; Their documentation is top-notch.  Only improvement that is needed is comment support to the manuals.
</li>
<li>
Community &#8211; Let&#8217;s face it. Doctrine has gained some traction and all you need to do is follow the mailing lists, IRC and other community resources to see they simply get it.  Their partnership with Zend Framework is a shining example of good strides in this area.</li>
</ul>
<p><b>Cons</b></p>
<ul>
<li>Hydration Override &#8211; This one had me scratching my head the first time I noticed it.  By default, if you fetch an object by the same primary key twice you don&#8217;t get two different copies, you get a pointer to the most recent version.  On the surface that makes sense but there are a number of reasons I don&#8217;t like this as the default setting.  Luckily you can turn this off through a configuration setting when you initialize Doctrine.</li>
<li>Hydration Speed &#8211; This is my biggest complaints with Doctrine.  If you run a query that pulls a parent/child relationship (i.e. a customer and their orders) this take a lot of time with Doctrine&#8217;s hydration method.  The complexity is the circular references you can get.  I don&#8217;t know why Propel handles this so much better but the impact is you can&#8217;t use Doctrine&#8217;s hydrated objects in you views.  The way around this, I&#8217;ll call the Doctrine Way, is to have them hydrated as arrays.  You still get the parent&#8217;s children, you just aren&#8217;t working with a native PHP object.  When you think about it, it make sense, though I still prefer having a choice. The performance hit you take, even on simple queries, makes the array hydration mandatory if you are pulling more than one or two records from the database.</li>
<li>No 5.3 namespace support &#8211; It too doesn&#8217;t support namespaces yet.</li>
</ul>
<p>This isn&#8217;t meant to be a comprehensive review of either system, rather, a punchlist of noteable things.  I don&#8217;t feel this blog post is near comprehensive enough to base your decision on, rather, it can be used in addition to your findings.  I&#8217;d love to hear the other pros and cons from either camps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybibbs.com/2010/02/comparing-propel-and-doctrine/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
