<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Christopher Shennan's Blog</title>
	
	<link>http://www.chrisshennan.com</link>
	<description>A day in the life of...</description>
	<lastBuildDate>Sat, 27 Feb 2010 21:04:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ChristopherShennansBlog" /><feedburner:info uri="christophershennansblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Wordpress wp_redirect() shows a blank page</title>
		<link>http://feedproxy.google.com/~r/ChristopherShennansBlog/~3/U6TphBedK3Q/</link>
		<comments>http://www.chrisshennan.com/2010/02/27/wordpress-wp_redirect-shows-a-blank-page/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 21:04:31 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[output_buffering]]></category>
		<category><![CDATA[php_flag]]></category>
		<category><![CDATA[redirection]]></category>
		<category><![CDATA[wordpress plugin]]></category>
		<category><![CDATA[wp_redirect]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=278</guid>
		<description><![CDATA[Over the last few weeks I have been working on my first wordpress plugin and I am quickly getting to grips with how it all pieces together but I ran into a problem with a rather basic piece of functionality that pretty much rendered the plugin useless until I figured out the issue.
The section I [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last few weeks I have been working on my first wordpress plugin and I am quickly getting to grips with how it all pieces together but I ran into a problem with a rather basic piece of functionality that pretty much rendered the plugin useless until I figured out the issue.</p>
<p>The section I was working on was a form submission (within the wordpress administation) which saved the form values into the database and then redirected the user upon success to another page (using wp_redirect) but this resulted in a blank content pane.</p>
<p>This seems very strange to me as it showed some of the page contents i.e. the header and left navigation but the content pane was completely blank.<br />
<span id="more-278"></span></p>
<p>I searched around for a few hours trying various suggestions to similar problems, downloading other wordpress plugins and examining how they used the wp_redirect function to see if the authors of these other wordpress plugins had done anything different, only to find that there was no difference.</p>
<p>I eventually managed to figure out the issue after I read a post regarding a problem another user was having where they were getting a completely blank screen and another member suggested the problem could be due to whitespace which was sent to the browser before the redirect was called resulting in a &#8220;headers already sent&#8221; problem.</p>
<p>This got me thinking that I did not have output buffering enabled which was strange as I usually have output buffering enabled to resolve this issue, however, in this case I did not have output buffering turned on and this turned out to be exactly the problem.  I added the following line to my .htaccess file and the redirection now works perfectly.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">php_flag output_buffering on</pre></div></div>

<p>I was glad to get this one resolved as I had to spend far too much time on something that I have resolved time and time again.  Certainly one I&#8217;ll be aware of should there be a next time!</p>
<img src="http://feeds.feedburner.com/~r/ChristopherShennansBlog/~4/U6TphBedK3Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2010/02/27/wordpress-wp_redirect-shows-a-blank-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chrisshennan.com/2010/02/27/wordpress-wp_redirect-shows-a-blank-page/</feedburner:origLink></item>
		<item>
		<title>Happy New Year 2010</title>
		<link>http://feedproxy.google.com/~r/ChristopherShennansBlog/~3/6_IkxIRpWlM/</link>
		<comments>http://www.chrisshennan.com/2010/01/01/happy-new-year-2010/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 15:33:44 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[new year]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=269</guid>
		<description><![CDATA[I just wanted to wish everyone a Happy New Year and all the best for 2010.  I hope that it proves to be a productive and successful year for you all.
I hope to get myself more motivated in 2010 and make 2010 a good year and work for me.  In this aim I hope to [...]]]></description>
			<content:encoded><![CDATA[<p>I just wanted to wish everyone a Happy New Year and all the best for 2010.  I hope that it proves to be a productive and successful year for you all.</p>
<p>I hope to get myself more motivated in 2010 and make 2010 a good year and work for me.  In this aim I hope to post a good few new blog entries on here over the next year and I&#8217;ve got a few in the pipeline already including a wordpress plugin I&#8217;m developing and moving <a href="http://www.managemyalerts.com" target="_blank">Manage My Alerts</a> over to Symfony 1.3/1.4 and I hope the entries I post are of use to you.</p>
<p>Once again I would like to wish you a Happy New Year and all the best for 2010.</p>
<h2>References</h2>
<p><a href="http://www.managemyalerts.com" target="_blank">Manage My Alerts</a> &#8211; An online reminder service</p>
<img src="http://feeds.feedburner.com/~r/ChristopherShennansBlog/~4/6_IkxIRpWlM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2010/01/01/happy-new-year-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chrisshennan.com/2010/01/01/happy-new-year-2010/</feedburner:origLink></item>
		<item>
		<title>User Profile Service Failed the Logon</title>
		<link>http://feedproxy.google.com/~r/ChristopherShennansBlog/~3/8rccgncXL_0/</link>
		<comments>http://www.chrisshennan.com/2009/12/29/user-profile-service-failed-the-logon/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 17:52:40 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[Computer Maintenance]]></category>
		<category><![CDATA[support]]></category>
		<category><![CDATA[Windows Vista]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=248</guid>
		<description><![CDATA[This Christmas was the quietest Christmas I have had in years in terms of the obligatory &#8220;if you have got the time&#8221; IT jobs as I only had 1 request for fixing a computer this year (instead of the 4 computers and a DVD player I had a few years back&#8230; all requested within 2 [...]]]></description>
			<content:encoded><![CDATA[<p>This Christmas was the quietest Christmas I have had in years in terms of the obligatory &#8220;if you have got the time&#8221; IT jobs as I only had 1 request for fixing a computer this year (instead of the 4 computers and a DVD player I had a few years back&#8230; all requested within 2 hours of arriving home).</p>
<p>Luckily this one turned out to be relatively simple and only took 5 minutes to fix although when I first heard about it I thought it was going to take a few hours.  My aunt and uncle reported a problem with logging into their laptop (running Windows Vista Home Premium) on my uncle&#8217;s profile where it would give an error message &#8220;The User Profile Service failed the logon&#8221;, after which it would simply return them to the profile selection screen.<br />
<span id="more-248"></span></p>
<p>I did a quick search using Safari on my <a href="/go/iphone" target="_blank">iPhone</a> and the first result which came up for &#8220;The User Profile Service failed the logon&#8221; sorted out my problem.</p>
<p>Seemingly the cause of the problem was that the profile had managed to enter a backup state and a registry amendment was needed to resolve the issue.  The registry amendment to fix my uncle&#8217;s issues with &#8220;The User Profile Service failed the logon&#8221; was as follows:-</p>
<ul>
<li style="text-align: left;">Log in to Windows using an alternative profile</li>
<li style="text-align: left;">Open regedit and go to HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\</li>
<li style="text-align: left;">Within the ProfileList key you should see 2 keys with almost identical names except one will have a suffix of .bak (i.e. S-1-5-21-1209794152-539799901-2903691368-1010 and S-1-5-21-1209794152-539799901-2903691368-1010.bak)</li>
<li style="text-align: left;">Delete the key <strong>WITHOUT</strong> the &#8220;.bak&#8221; suffix</li>
<li style="text-align: left;">Rename the other key and remove the &#8220;.bak&#8221; suffix</li>
<li style="text-align: left;">Edit the &#8220;State&#8221; DWORD within the renamed key and set to &#8220;0&#8243; (zero)</li>
</ul>
<p>After that we were able to restart the computer and log back in under my uncle&#8217;s profile without any more problems and no more &#8220;The User Profile Service failed the logon&#8221; messages.</p>
<h2>Sources</h2>
<p><a href="http://forums.techarena.in/vista-help/692126.htm" target="_blank">TechArena Community &#8211; The User Profile Service failed the logon</a></p>
<img src="http://feeds.feedburner.com/~r/ChristopherShennansBlog/~4/8rccgncXL_0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/12/29/user-profile-service-failed-the-logon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chrisshennan.com/2009/12/29/user-profile-service-failed-the-logon/</feedburner:origLink></item>
		<item>
		<title>New Website:  The Weekly Whinge</title>
		<link>http://feedproxy.google.com/~r/ChristopherShennansBlog/~3/R9J6Q_mgmEQ/</link>
		<comments>http://www.chrisshennan.com/2009/12/08/new-website-the-weekly-whinge/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 07:16:20 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[complain]]></category>
		<category><![CDATA[complaint]]></category>
		<category><![CDATA[new site]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[whinge]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=243</guid>
		<description><![CDATA[Over the weekend I launched our newest site, The Weekly Whinge, which was set up as a place for me to vent my frustration and generally just rant and complain about life.  As it has only just been launched my whinge list is relatively small so far but I&#8217;m finding ideas all over the [...]]]></description>
			<content:encoded><![CDATA[<p>Over the weekend I launched our newest site, <a href="http://www.theweeklywhinge.com" target="_blank">The Weekly Whinge</a>, which was set up as a place for me to vent my frustration and generally just rant and complain about life.  As it has only just been launched my whinge list is relatively small so far but I&#8217;m finding ideas all over the place, on the way to work, out doing the Christmas shopping (it is probably best that I do not start on that one or I will never end), even with just updating this blog so I am sure there will be many more additions to <a href="http://www.theweeklywhinge.com" target="_blank">The Weekly Whinge</a> before long.<br />
<span id="more-243"></span></p>
<p>Currently the whinge list consists of:-</p>
<ul>
<li><a href="http://www.theweeklywhinge.com/2009/12/change-of-domain-because-of-cyber-squatter/" target="_blank">Change of Domain because of a Cyber Squatter</a> &#8211; The domain I originally wanted was already taken so I was forced to chosen an alternative.</li>
<li><a href="http://www.theweeklywhinge.com/2009/12/wordpress-snow-effects/" target="_blank">Wordpress Snow Effects</a> &#8211; Silly visual effects on Wordpress blogs making me question my vision.</li>
</ul>
<p>I have decided to allow visitors to <a href="http://www.theweeklywhinge.com/" target="_blank">The Weekly Whinge</a> to submit their own whinges via the <a href="http://www.theweeklywhinge.com/have-your-whinge/" target="_blank">Have Your Whinge</a> page and I will endeavour to put these whinges up on <a href="http://www.theweeklywhinge.com/" target="_blank">The Weekly Whinge</a> along with my own.</p>
<p>So do not bottle it all up inside.  Share your whinge and see it posted on <a href="http://www.theweeklywhinge.com/" target="_blank">The Weekly Whinge</a>!</p>
<img src="http://feeds.feedburner.com/~r/ChristopherShennansBlog/~4/R9J6Q_mgmEQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/12/08/new-website-the-weekly-whinge/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.chrisshennan.com/2009/12/08/new-website-the-weekly-whinge/</feedburner:origLink></item>
		<item>
		<title>Raw SQL from Doctrine Query Object – Revised</title>
		<link>http://feedproxy.google.com/~r/ChristopherShennansBlog/~3/x1-ftO18Hwo/</link>
		<comments>http://www.chrisshennan.com/2009/12/07/raw-sql-from-doctrine-query-object-revised/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 19:47:21 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[doctine]]></category>
		<category><![CDATA[doctrine query object]]></category>
		<category><![CDATA[raw sql]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=232</guid>
		<description><![CDATA[A few months ago I posted an article taking about how to get the raw SQL from a Doctrine Query Object but with the release of Symfony 1.3 and Symfony 1.4 it would appear that the code no longer works.  As a result I&#8217;ve updated the code to work with Symfony 1.2 &#8211; 1.4 and [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago I posted an article taking about how to get the <a href="/2009/09/22/raw-sql-from-a-doctrine-query-object/" target="_self">raw SQL from a Doctrine Query Object</a> but with the release of <a href="http://www.symfony-project.org/installation/1_3" target="_blank">Symfony 1.3</a> and <a href="http://www.symfony-project.org/installation/1_4" target="_blank">Symfony 1.4</a> it would appear that the code no longer works.  As a result I&#8217;ve updated the code to work with Symfony 1.2 &#8211; 1.4 and you can find the updated source below:-<br />
<span id="more-232"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_raw_sql<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span> instanceof Doctrine_Query<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        throw <span style="color: #000000; font-weight: bold;">new</span> sfException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Not an instanse of a Doctrine Query'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">limit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_callable</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'buildSqlQuery'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$queryString</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">buildSqlQuery</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$query_params</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParams</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query_params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'where'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$queryString</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSql</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParams</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$queryStringParts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'\?'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$queryString</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$iQC</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$queryString</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$queryString</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$queryStringParts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$iQC</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$param</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_bool</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$queryString</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$queryStringParts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$iQC</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$param</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$queryString</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$queryStringParts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$iQC</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'\''</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$param</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'\''</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000088;">$iQC</span><span style="color: #339933;">++;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$iQC</span><span style="color: #339933;">;</span><span style="color: #000088;">$iQC</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$queryStringParts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$iQC</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #000088;">$queryString</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$queryStringParts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$iQC</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$queryString</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I hope that it proves useful.</p>
<img src="http://feeds.feedburner.com/~r/ChristopherShennansBlog/~4/x1-ftO18Hwo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/12/07/raw-sql-from-doctrine-query-object-revised/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.chrisshennan.com/2009/12/07/raw-sql-from-doctrine-query-object-revised/</feedburner:origLink></item>
		<item>
		<title>csNews Pro</title>
		<link>http://feedproxy.google.com/~r/ChristopherShennansBlog/~3/sNp-1uhkJsA/</link>
		<comments>http://www.chrisshennan.com/2009/11/22/csnews-pro/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 19:01:32 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cNews pro]]></category>
		<category><![CDATA[design2host]]></category>
		<category><![CDATA[v-desk]]></category>
		<category><![CDATA[v-desk newsletter system]]></category>
		<category><![CDATA[v-desk.com]]></category>
		<category><![CDATA[vdesk]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=225</guid>
		<description><![CDATA[It&#8217;s taken me a while but I&#8217;ve finally managed to create the &#8220;My Projects&#8221; section started although in all likelyhood I&#8217;ll not have much time to devote to my projects.
I&#8217;ve started off by resurrection an old project that I worked on while I was self employed as Design2Host Ltd.  csNews Pro (formerly V-Desk Newsletter System [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s taken me a while but I&#8217;ve finally managed to create the &#8220;<a href="/my-projects/">My Projects</a>&#8221; section started although in all likelyhood I&#8217;ll not have much time to devote to my projects.</p>
<p>I&#8217;ve started off by resurrection an old project that I worked on while I was self employed as Design2Host Ltd.  <a href="/my-projects/csnews-pro-formerly-v-desk-newsletter-system-pro/">csNews Pro (formerly V-Desk Newsletter System Pro)</a> has had a few cosmetic details changed (changed the name, removed the licence key limitions) but it&#8217;s exactly the same project and it is compatible with the paid version that was original available so you can easily convert from the previous paid version across to the free version when any updates become available.</p>
<p>Feel free to download and play with <a href="/my-projects/csnews-pro-formerly-v-desk-newsletter-system-pro/">csNews Pro</a> and feel free to give my any feedback on it.</p>
<img src="http://feeds.feedburner.com/~r/ChristopherShennansBlog/~4/sNp-1uhkJsA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/11/22/csnews-pro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chrisshennan.com/2009/11/22/csnews-pro/</feedburner:origLink></item>
		<item>
		<title>TRUNCATE TABLE with Symfony and Doctrine</title>
		<link>http://feedproxy.google.com/~r/ChristopherShennansBlog/~3/WeY9COYgaF8/</link>
		<comments>http://www.chrisshennan.com/2009/11/20/truncate-table-with-symfony-and-doctrine/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 20:59:25 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[doctrine truncate table]]></category>
		<category><![CDATA[mysql truncate table]]></category>
		<category><![CDATA[symfony import routines]]></category>
		<category><![CDATA[symfony truncate table]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=178</guid>
		<description><![CDATA[I am often importing data into a symfony project from an existing site or a CSV file and re-writing this data into the fixtures.yml is usually too complicated or time consuming so I end up writing bespoke import actions.
While I am writing these actions I often find that I have to delete the contents of [...]]]></description>
			<content:encoded><![CDATA[<p>I am often importing data into a symfony project from an existing site or a CSV file and re-writing this data into the fixtures.yml is usually too complicated or time consuming so I end up writing bespoke import actions.</p>
<p>While I am writing these actions I often find that I have to delete the contents of the MySQL tables as you can never write the routine complete and accurate in one go so as you build it up in smaller steps you find that you have to get rid of the previously old data.</p>
<p>This presented me with 2 problems:-</p>
<ul>
<li>Using DELETE FROM [TABLENAME] does not reset the auto-incrementing fields so if you have anything that is based on the id during the rest of the import then you&#8217;re going to have issues.</li>
<li>There is a lot of clicking in phpMyAdmin to empty the tables, especially if you forget about the foreign key relationships.</li>
</ul>
<p><span id="more-178"></span></p>
<p>I found that MySQL had a TRUNCATE TABLE but this is not directly available via Doctrine as the TRUNCATE TABLE is function of the type of database you are using and Doctrine cannot assume you are always using MySQL so therefore it cannot provide a generic method to call it.</p>
<p>Having said that it was not too difficult to run the TRUNCATE TABLE from within my Symfony project.  All I had to do was add the following lines of code to an action within the actions.class.php for my import module and now it empties each table I have defined before importing the data and it also resets the auto-incrememt ids all my tables start from id = 1 each time I run the import.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$doctrine</span> <span style="color: #339933;">=</span> Doctrine_Manager<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCurrentConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDbh</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$doctrine</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'TRUNCATE TABLE order_items'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$doctrine</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'TRUNCATE TABLE orders'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$doctrine</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Be careful which order you run the TRUNCATE TABLE calls so you avoid the foreign key relationship issues.</p>
<p>Let me know if this helps you out.  Enjoy!</p>
<img src="http://feeds.feedburner.com/~r/ChristopherShennansBlog/~4/WeY9COYgaF8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/11/20/truncate-table-with-symfony-and-doctrine/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.chrisshennan.com/2009/11/20/truncate-table-with-symfony-and-doctrine/</feedburner:origLink></item>
		<item>
		<title>Magento API – Update Product Stock Levels</title>
		<link>http://feedproxy.google.com/~r/ChristopherShennansBlog/~3/CsveCsdttbA/</link>
		<comments>http://www.chrisshennan.com/2009/11/15/magento-api-update-product-stock-levels/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 18:23:00 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[magento api]]></category>
		<category><![CDATA[magento stock levels]]></category>
		<category><![CDATA[product.update]]></category>
		<category><![CDATA[product_stock.update]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=162</guid>
		<description><![CDATA[Another day&#8230; another magento problem!
I was asked to look into a problem with an automated stock level update script not updating the stock levels.  This update script was using the Magento API and on the face of things everything looked ok as the script ran without any errors, the product prices got updated but the [...]]]></description>
			<content:encoded><![CDATA[<p>Another day&#8230; another magento problem!</p>
<p>I was asked to look into a problem with an automated stock level update script not updating the stock levels.  This update script was using the Magento API and on the face of things everything looked ok as the script ran without any errors, the product prices got updated but the stock levels never changed.</p>
<p>After a bit of investigating I found the problem was caused by an incorrect usage of the Magento API and the original update statement was similar to:-</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$proxy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sessionId</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'product.update'</span><span style="color: #339933;">,</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'PRD0001'</span><span style="color: #339933;">,</span> 
		<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'price'</span><span style="color: #339933;">=&gt;</span><span style="color:#800080;">12.50</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">'qty'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">12</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">'is_in_stock'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">'discontinued'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">0</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>However, the update of the is_in_stock and qty fields is not done against the product (via <a href="http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_product" target="_blank">product.update</a>) but against the product inventory (via <a href="http://www.magentocommerce.com/wiki/doc/webservices-api/api/cataloginventory_stock_item" target="_blank">product_stock.update</a>) so this code had to be updated to the following:-<br />
<span id="more-162"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// UPDATE THE PRODUCT</span>
<span style="color: #000088;">$proxy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sessionId</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'product.update'</span><span style="color: #339933;">,</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'PRD0001'</span><span style="color: #339933;">,</span> 
		<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'price'</span><span style="color: #339933;">=&gt;</span><span style="color:#800080;">12.50</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">'discontinued'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">0</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// UPDATE THE PRODUCT INVENTORY</span>
<span style="color: #000088;">$proxy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">call</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sessionId</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'product_stock.update'</span><span style="color: #339933;">,</span>
	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'PRD0001'</span><span style="color: #339933;">,</span> 
		<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'qty'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">12</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">'is_in_stock'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> 
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>After the stock level update script had been adapted to this 2 step approach everything seemed to run ok and the stock level figures were then being updated with the appropriate quantities.</p>
<img src="http://feeds.feedburner.com/~r/ChristopherShennansBlog/~4/CsveCsdttbA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/11/15/magento-api-update-product-stock-levels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.chrisshennan.com/2009/11/15/magento-api-update-product-stock-levels/</feedburner:origLink></item>
		<item>
		<title>My XBOX sounds like a hoover!</title>
		<link>http://feedproxy.google.com/~r/ChristopherShennansBlog/~3/HSouoWLy-xo/</link>
		<comments>http://www.chrisshennan.com/2009/10/29/my-xbox-sounds-like-a-hoover/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 13:02:32 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[dyson]]></category>
		<category><![CDATA[xbox]]></category>
		<category><![CDATA[xbox noise]]></category>
		<category><![CDATA[xbox noise problems]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=155</guid>
		<description><![CDATA[Back in February 2009 I treated myself to a Resident Evil XBOX 360 Elite from Game and in all honesty I haven&#8217;t really played it much.  It&#8217;s only been on maybe 10 days since I&#8217;ve bought it but I&#8217;ve got a bit more time of my hands these days so I&#8217;m starting to play [...]]]></description>
			<content:encoded><![CDATA[<p>Back in February 2009 I treated myself to a Resident Evil XBOX 360 Elite from Game and in all honesty I haven&#8217;t really played it much.  It&#8217;s only been on maybe 10 days since I&#8217;ve bought it but I&#8217;ve got a bit more time of my hands these days so I&#8217;m starting to play it more and I&#8217;ve noticed that is sounds like a hoover when you&#8217;re playing a game.</p>
<p>I&#8217;m usually playing my XBOX at night and I have to keep the TV volume down so the audio is instantly drowned out by the noise of the XBOX and I would actually go as far as saying that my hoover is quieter than the XBOX (that may be a slight exaggeration but not by much!) so there isn&#8217;t that much that I would consider &#8220;Elite&#8221; about this XBOX.</p>
<p><span id="more-155"></span></p>
<p>So off I went and emailed Microsoft about this problem and what they would do about it (mainly because I was being lazy and was hoping they would pick it up and drop off a new one rather than me have to take it back to the store) and I got the following response:-</p>
<blockquote><p>Thank you for contacting Xbox Support.</p>
<p>To deliver high definition gaming experiences, the Xbox 360 packs state-of-the-art processing power into a small package. To create an optimal operating environment for hardware with that kind of power, special considerations were taken to control the temperature of the console by optimizing the speed of the cooling fan. Additionally, the Xbox 360 features a high-end disc drive that spins at a very fast rate. These factors combine to enable faster response times and high fidelity, high definition games with more characters, and richer worlds than ever before. We&#8217;re confident that as soon as gamers see the spectacular Xbox 360 graphics and hear the amazing surround sound in the games, they&#8217;ll understand why we&#8217;ve packed so much power into the system.</p>
<p>Kind regards</p></blockquote>
<blockquote><p>Xbox Service and Support Team</p></blockquote>
<p>To me that doesn&#8217;t answer my question at all and sounds more like &#8220;thank you for buying a dyson&#8221;.  Maybe if I buy a dyson then I&#8217;ll actually get my XBOX!</p>
<img src="http://feeds.feedburner.com/~r/ChristopherShennansBlog/~4/HSouoWLy-xo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/10/29/my-xbox-sounds-like-a-hoover/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.chrisshennan.com/2009/10/29/my-xbox-sounds-like-a-hoover/</feedburner:origLink></item>
		<item>
		<title>Raw SQL from a Doctrine Query Object</title>
		<link>http://feedproxy.google.com/~r/ChristopherShennansBlog/~3/uqVcRRjWcwQ/</link>
		<comments>http://www.chrisshennan.com/2009/09/22/raw-sql-from-a-doctrine-query-object/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 19:01:49 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[doctrine]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=138</guid>
		<description><![CDATA[This has been updated to work with Symfony 1.3/1.4 &#8211; Please go to the updated article:  Raw SQL from Doctrine Query Object – Revised
As my use of Symfony is increasing I find myself frustrated that there doesn&#8217;t appear to be an easy way to get the raw SQL from a doctrine query object so [...]]]></description>
			<content:encoded><![CDATA[<p><strong>This has been updated to work with Symfony 1.3/1.4 &#8211; Please go to the updated article:  <a href="/2009/12/07/raw-sql-from-doctrine-query-object-revised/">Raw SQL from Doctrine Query Object – Revised</a></strong></p>
<p>As my use of Symfony is increasing I find myself frustrated that there doesn&#8217;t appear to be an easy way to get the raw SQL from a doctrine query object so I can simply output it and paste it into phpMyAdmin to debug problems with the SQL.  I may be wrong about this but as yet I have not found a built in function to perform this operation.</p>
<p>Sure I am able to output the query with the &#8220;?&#8221; indicating where the necessary values are to go and I can also easily output the array of query parameters so I can substitute these manually but this takes time and it would be much much simpler and quicker to just output the whole query with the substitution already done so it&#8217;s a simply copy and paste of the raw SQL from the doctrine query object straight into phpMyAdmin.</p>
<p>I have wrote a quick function to do this and I had meant to post this for a while but I just have not had the chance to get round to it until now.<br />
<span id="more-138"></span><br />
The code for this is can be found below:-</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_raw_sql<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">limit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$queryStringParts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'\?'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSQL</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$iQC</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$queryString</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParams</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$queryString</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$queryStringParts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$iQC</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$param</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_bool</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$param</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$queryString</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$queryStringParts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$iQC</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$param</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$queryString</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$queryStringParts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$iQC</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'\''</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$param</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'\''</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$iQC</span><span style="color: #339933;">++;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$iQC</span><span style="color: #339933;">;</span><span style="color: #000088;">$iQC</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$queryStringParts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$iQC</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #000088;">$queryString</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$queryStringParts</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$iQC</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$queryString</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In my case this is a global function but it could very well be written as a static function in a debug class.</p>
<p>$query is a Doctrine Query object and this function iterates round the parameters for the query string and replaces each instance of a &#8220;?&#8221; with the corresponding variable.  It has a crude (but fairly effective so far) method of determine whether it&#8217;s a string, number or boolean when performing this substitution and so far this works well in all the cases I&#8217;ve used it.</p>
<p>The $query->limit(0); is very important as the $query->getSQL() function does not work properly in this context if a limit is specified on the query so as we are wanting to debug the SQL and a majority of the time we are not concerned with the limit I have opted to remove this from this routine.</p>
<p>Hopefully this will allow you to save some time and effort trying to get the raw SQL from your doctrine query objects and I would appreciated any comments, thoughts or ideas you may have for improvement.</p>
<img src="http://feeds.feedburner.com/~r/ChristopherShennansBlog/~4/uqVcRRjWcwQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/09/22/raw-sql-from-a-doctrine-query-object/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.chrisshennan.com/2009/09/22/raw-sql-from-a-doctrine-query-object/</feedburner:origLink></item>
	</channel>
</rss>
