<?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>woblog &#187; Programming</title>
	<atom:link href="http://www.whiteoctober.co.uk/blog/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.whiteoctober.co.uk/blog</link>
	<description>great stuff about the web</description>
	<lastBuildDate>Mon, 05 Dec 2011 16:53:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Programming for fun when you&#8217;re a programmer</title>
		<link>http://www.whiteoctober.co.uk/blog/2009/01/28/programming-for-fun-when-youre-a-programmer/</link>
		<comments>http://www.whiteoctober.co.uk/blog/2009/01/28/programming-for-fun-when-youre-a-programmer/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 14:39:32 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.whiteoctober.co.uk/blog/?p=242</guid>
		<description><![CDATA[The excellent Stack Overflow developer forum site (brough to you by Joel Spolksy amongst others) is chock full of highly technical questions such as: Why Does This Pointer-Pointer Initialization Seg Fault? Query Strings &#38; Mod ReWrite How many constructors should a class have? But some of the questions are a little more philosophical. And here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>The excellent <a href="http://stackoverflow.com/">Stack Overflow</a> developer forum site (brough to you by <a href="http://www.joelonsoftware.com/">Joel Spolksy</a> amongst others) is chock full of highly technical questions such as:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/487566/why-does-this-pointer-pointer-initialization-seg-fault">Why Does This Pointer-Pointer Initialization Seg Fault?</a></li>
<li><a href="http://stackoverflow.com/questions/487726/query-strings-mod-rewrite">Query Strings &amp; Mod ReWrite</a></li>
<li><a href="http://stackoverflow.com/questions/490661/how-many-constructors-should-a-class-have">How many constructors should a class have?<br />
</a></li>
</ul>
<p>But some of the questions are a little more philosophical. And here&#8217;s one that&#8217;s troubled me from time to time:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/487169/finding-the-time-to-program-in-your-spare-time">Finding the time to program in your spare time?</a></li>
</ul>
<p>I&#8217;m developing pretty much all day for White October. There are lots of geeky little side projects I&#8217;d like to do more of: sorting out my own website, community websites, open source things, computers for art and creative stuff, etc. But it&#8217;s difficult when you&#8217;re sat in front of a computer all day to get back in front of it after tea and do your own thing. So the weekends seem more favourable. But then there are lots of other things to be getting on with, both fun and not so much fun.</p>
<p>Hmm. Perhaps the only answer is to switch careers and become a milkman or something.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.whiteoctober.co.uk/blog/2009/01/28/programming-for-fun-when-youre-a-programmer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Why I hate Criteria&#8221;</title>
		<link>http://www.whiteoctober.co.uk/blog/2008/10/08/why-i-hate-criteria/</link>
		<comments>http://www.whiteoctober.co.uk/blog/2008/10/08/why-i-hate-criteria/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 12:46:06 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[Object-relational mapping]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.whiteoctober.co.uk/blog/?p=153</guid>
		<description><![CDATA[Nicking the title from the previous post, oh and the sentiment. I don&#8217;t hate Criteria**, it is actually quite good, however watching the video in the previous post reminded me of a few issues we have had in the office where we have complained about it or just got plain confused&#8230; I know Dan, for [...]]]></description>
			<content:encoded><![CDATA[<p>Nicking the title from the <a href="http://www.whiteoctober.co.uk/blog/2008/10/07/why-i-hate-django/">previous post</a>, oh and the sentiment.  I don&#8217;t hate <a href="http://propel.phpdb.org/trac/wiki/Users/Documentation/1.3/Criteria">Criteria</a>**, it is actually quite good, however watching the video in the previous post reminded me of a few issues we have had in the office where we have complained about it or just got plain confused&#8230;</p>
<p>I know <a href="http://www.whiteoctober.co.uk/meet-the-staff-_27.html#dan">Dan</a>, for example, doesn&#8217;t see the point of using Criteria because what is wrong with SQL?</p>
<p>I have sat and scratched my head a few times trying to figure out how to query using Criteria, I know how I would do it in SQL but I can sit for ages trying to bend Criteria to my will.</p>
<p>I really should have <a href="http://propel.phpdb.org/trac/wiki/Users/Documentation/1.3/Criteria">RTFM</a>&#8230;</p>
<p style="padding-left: 30px;"><em>We do still recommend that you use SQL when it proves to be simpler, though.</em></p>
<p>Criteria is great when it fits your needs, but when it doesn&#8217;t or becomes very complex..stop step back and use SQL.</p>
<p>Using <a href="http://propel.phpdb.org/trac/">Propel 1.3</a> you get to use <a href="http://uk.php.net/manual/en/intro.pdo.php">PDO</a> and that is not something that is framework specific it&#8217;s an inbuilt <a href="http://www.php.net">PHP</a> database abstraction layer. So the skills you learn using PDO are transferable to another project that doesn&#8217;t use a framework but uses a database.</p>
<p>So we have a custom query that we want to run and get back a bunch of user objects and we really don&#8217;t want to use Criteria&#8230;easy:</p>
<p style="padding-left: 30px;">$name = &#8220;Wards&#8221;;<em><br />
</em>$bunchofusers = array();<em><br />
//Our highly complex query&#8230;.<br />
//Fancy prepared stuff you get from PDO&#8230;think sprintf<br />
</em>$stmt = $con-&gt;prepare(&#8220;SELECT * FROM user WHERE last_name = ?&#8221;);<br />
$stmt-&gt;bindValue(1, $name);<em><br />
//erm execute&#8230;<br />
</em>$stmt-&gt;execute();<em><br />
//Loop on our rows&#8230;and lets make some User objects..<br />
</em>while($row = $stmt-&gt;fetch()) {<br />
$oUser = new User();<br />
$oUser-&gt;hydrate($row);<br />
$bunchofusers[]=$oUser;<br />
}</p>
<p>Nothing really new to learn in the above code, it&#8217;s more like remembering that we can code how we choose too and we don&#8217;t have to be shackled to a certain way or slowed down by a framework when things don&#8217;t exactly fit.</p>
<p>** <em>&#8220;What is Criteria?&#8221; I hear you say&#8230;well it comes with the Propel ORM, and it is for building up queries using objects rather than SQL. We use Propel within the <a href="http://www.symfony-project.org/">symfony framework</a> as our current ORM of choice.</em></p>
<div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/a771d9f4-e213-47b4-b5f8-cafd6ee09603/"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_c.png?x-id=a771d9f4-e213-47b4-b5f8-cafd6ee09603" alt="Reblog this post [with Zemanta]" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.whiteoctober.co.uk/blog/2008/10/08/why-i-hate-criteria/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding propel objects</title>
		<link>http://www.whiteoctober.co.uk/blog/2008/04/15/finding-propel-objects/</link>
		<comments>http://www.whiteoctober.co.uk/blog/2008/04/15/finding-propel-objects/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 08:42:04 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[Web technologies]]></category>
		<category><![CDATA[Object-relational mapping]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.whiteoctober.co.uk/blog/?p=42</guid>
		<description><![CDATA[In the White October office we use a programing framework called Symfony for some of our projects. It provides us with well erm a framework to develop our web applications, it gives us a standard way of dealing with web requests, keeping our code in a standard set of folders and lots of handy tools [...]]]></description>
			<content:encoded><![CDATA[<p>In the White October office we use a programing framework called <a class="zem_slink" title="Symfony" rel="homepage" href="http://www.symfony-project.com/" target="_blank">Symfony</a> for some of our projects. It provides us with well erm a framework to develop our web applications, it gives us a standard way of dealing with web requests, keeping our code in a standard set of folders and lots of handy tools to speed up the development of applications.</p>
<p>One such tool is the <a class="zem_slink" title="Propel (PHP)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Propel_%28PHP%29" target="_blank">Propel</a> <a class="zem_slink" title="Object-relational mapping" rel="wikipedia" href="http://en.wikipedia.org/wiki/Object-relational_mapping" target="_blank">ORM</a> which gives us objects to represent the tables we have in databases, it reduces the amount of <a class="zem_slink" title="SQL" rel="wikipedia" href="http://en.wikipedia.org/wiki/SQL" target="_blank">SQL</a> you have to write in an application to almost nil.</p>
<p>Sometimes however searching for information in a table can be a lot harder in Propel that it would be in SQL, you have to use &#8220;Criteria&#8221; objects and they are not as intuitive as they should be.</p>
<p>However <a href="http://redotheweb.com/"> François Zaninotto</a>, one of the creators of the Symfony framework, has <a href="http://redotheweb.com/2008/04/10/propel-is-not-hard-anymore/">written a finder plugin</a> for Propel Objects called <a href="http://trac.symfony-project.com/wiki/sfPropelFinderPlugin">sfPropelFinderPlugin</a> which aims to make this process a lot easier and more intuitive.<br />
<code><br />
// With Peer and Criteria<br />
$c = new Criteria()<br />
$c-&gt;add(ArticlePeer::TITLE, '%world', Criteria::LIKE);<br />
$c-&gt;add(ArticlePeer::IS_PUBLISHED, true);<br />
$c-&gt;addAscendingOrderByColumn(ArticlePeer::CREATED_AT);<br />
$articles = ArticlePeer::doSelect($c);<br />
// with sfPropelFinder<br />
$articles = sfPropelFinder::from('Article')-&gt;whereTitle('like', '%world')-&gt;whereIsPublished(true)-&gt;orderByCreatedAt()-&gt;find();<br />
</code><br />
If you use Propel outside of Symfony you can also use this plugin as it is standalone.</p>
<p>I like the quote from the wiki page.<br />
<strong> &#8220;Think of sfPropelFinder as <a class="zem_slink" title="JQuery" rel="homepage" href="http://jquery.com/" target="_blank">jQuery</a> for Propel&#8221;</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.whiteoctober.co.uk/blog/2008/04/15/finding-propel-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

