<?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>bybjorn.com &#124; Bjørn Børresen - freelance web developer &#187; orm</title>
	<atom:link href="http://www.bybjorn.com/tag/orm/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bybjorn.com</link>
	<description>bybjorn.com &#62;&#62; Bjørn Børresen - freelance web developer</description>
	<lastBuildDate>Mon, 03 Oct 2011 13:39:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>PEAR DataObjects vs. Propel vs. EzPDO vs .. Java!</title>
		<link>http://www.bybjorn.com/31/</link>
		<comments>http://www.bybjorn.com/31/#comments</comments>
		<pubDate>Wed, 05 Apr 2006 20:36:48 +0000</pubDate>
		<dc:creator>Bjørn Børresen</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[pdo]]></category>

		<guid isPermaLink="false">http://bie.no/blog/computers/software-engineering/php/2006/04/pear-dataobjects-vs-propel-vs-ezpdo-vs-java/</guid>
		<description><![CDATA[Using an object perstistence layer can be greatly benefitial for any medium to large size project. Or, any project at all some would say. If you don&#8217;t know what I&#8217;m talking about, I&#8217;ll give you a quick example. Usually, in PHP we would do something ugly-bugly like this to retrieve info about a certain item [...]]]></description>
			<content:encoded><![CDATA[<p>Using an object perstistence layer can be greatly benefitial for any medium to large size project. Or, <em>any</em> project at all some would say. If you don&#8217;t know what I&#8217;m talking about, I&#8217;ll give you a quick example. Usually, in PHP we would do something ugly-bugly like this to retrieve info about a certain item in the database:</p>

<blockquote>$res = mysql_query(&#8220;SELECT * FROM article WHERE ID=5&#8243;);
if($row == mysql_fetch_assoc($res)) {
echo $row["title"];
// do something here
}</blockquote>

<p>Compare it to this:</p>

<blockquote>$article = new Article(5);
echo $article->getTitle();
// do something here</blockquote>

<p>Ah, the beauty of OO.</p>

<p>My first experience with this was the <a href="http://pear.php.net/package/DB_DataObject/">PEAR DataObject</a> package. I was amazed &#8211; it could generate classes based on the tables found in my database automatically, and I could start using them instantly! Yummy!</p>

<p>Lately I&#8217;ve been having a look at <a href="http://propel.phpdb.org">Propel</a>. You see, I know the <a href="http://www.symfony-project.com">Symfony</a> guys chose Propel, and after <a href="http://podcast.phparch.com/main/index.php/episodes:20060210">listening to a podcast with an interview</a> with one of the project leads there, I&#8217;m convinced that the guys behind symfony are smart. Smart people choose the best frameworks, so my logic tells me to look at Propel <img src='http://www.bybjorn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p>I haven&#8217;t tried it yet &#8211; but at first glance it looks better than PEAR DO. Why? Well, Propel will generate 4 classes for each table in your database. Overkill you say? Well, read this from the Symfony Model documentation:</p>

<blockquote>Why keep two versions of the data object model, one in <code>model/om/</code> and another in <code>model/</code>?</blockquote>

<blockquote>You will probably need to add custom methods and attributes to the model objects (think about the <code>->getName()</code> method that outputs the <code>FirstName</code> and <code>LastName</code> together). But as your project develops, you will also add tables or columns. Whenever you change the <code>schema.xml</code>, you have to make a new call to <code>symfony propel-build-model</code> to generate the object model classes.

The <code>Base</code> architecture allows you to keep using the <code>symfony propel-build-model</code> command even after you added custom code to your classes. Here is how it works: the <code>Base</code> classes kept in the <code>model/om/</code> directory are the ones generated by Propel. You should <strong>never</strong> modify them since every new build of the model will completely erase these files. But if you need to add custom methods, use the regular object classes of the <code>model/</code> directory that actually inherit from the previous ones.

<a href="/content/book/page/model.html"></a></blockquote>

<p>Of course, you could just extend the PEAR DataObjects created but it just &#8230; well, it just doesn&#8217;t seem to be encouraged. I like when a framework encourage me to do stuff The Right Way(TM).</p>

<p>So, Propel it is, I thought &#8211; but that was before a co-worker of mine suggested <a href="http://www.ezpdo.net">EzPDO</a> which supposedly had a bit of a different approach. They brand themselves as &#8220;A simple solution for PHP Object Relational Mapping and Data Persistence&#8221; and they seem to be worth a look.</p>

<p>The final solution I&#8217;m looking at for solving this issue is using Java combined with PHP. Using the new Zend Platform it&#8217;s possible to use Java objects, in PHP code &#8211; is that great or what. A little illustration for you, which I found <a href="http://www.zend.com/store/products/zend-platform/java.php">here</a>.</p>

<div style="text-align: center"><img title="java in php" alt="java in php" src="http://www.zend.com/images/store/zend-platform/javabridge_img.gif" /></div>

<p>That way the db stuff can be handled in EJB&#8217;s maybe, everything is transferred via SOAP and I can use objects in PHP like I would with Propel etc. It&#8217;s all a bit sketchy, but it&#8217;s something I&#8217;m looking at.</p>

<p>Comments anyone? I&#8217;d love to hear some feedback from people who have actually done this ..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bybjorn.com/31/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

