<?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>Christopher Shennan's Blog &#187; PHP</title>
	<atom:link href="http://www.chrisshennan.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chrisshennan.com</link>
	<description>A day in the life of...</description>
	<lastBuildDate>Wed, 01 Sep 2010 13:00:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Method Signatures &#8211; Pass values as individual parameters or an option array?</title>
		<link>http://www.chrisshennan.com/2010/08/25/method-signatures-pass-values-as-individual-parameters-or-an-option-array/</link>
		<comments>http://www.chrisshennan.com/2010/08/25/method-signatures-pass-values-as-individual-parameters-or-an-option-array/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 11:07:47 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[method signatures]]></category>
		<category><![CDATA[options array]]></category>
		<category><![CDATA[parameter passing]]></category>
		<category><![CDATA[parameters vs option array]]></category>
		<category><![CDATA[parameters vs options]]></category>
		<category><![CDATA[symfony options array]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=330</guid>
		<description><![CDATA[Over the last few months I have been working with Symfony and have got used to passing values to methods via an options array but I have recently had to pick up an older project in which the values are passed to the methods by individual parameters. 
This has given me a good opportunity to [...]]]></description>
			<content:encoded><![CDATA[<h4><span style="font-weight: normal;">Over the last few months I have been working with Symfony and have got used to passing values to methods via an options array but I have recently had to pick up an older project in which the values are passed to the methods by individual parameters. </span></h4>
<h4><span style="font-weight: normal;">This has given me a good opportunity to evaluate both techniques and determine my personal preference for working.</span></h4>
<p>The more traditional technique is to pass values to methods using individual parameters as in the example below:-</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> someMethod<span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$age</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// do something</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The benefit I have found with this method is that you can clearly identify what needs to be passed to the method, however, if you need to change the method to include an additional parameter it means that you have to update every call to this method so that every parameter is specified.<br />
<span id="more-330"></span><br />
An alternative (and my personal preference) is to used an option array like in the following example</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> someMethod<span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">// do something</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In this case, if you need to add an extra parameter to the method you can simply add the value to the options array and update the functionality within the method.  You do not necessarily need to update the calls to this method that are already in place  because they should still work fine provided the updated functionality is defined in such a way that it allows for the new parameter to be optional.</p>
<p>In addition, I feel that if you provide decent documentation regarding the options array (which should include a list of all the options values allowed), especially if it can be picked up via auto-completion in IDEs such as <a href="http://www.netbeans.com/" target="_blank">Netbeans</a>, then this is just as easy to use as methods which are defined to accept individual parameters.</p>
<h4>References</h4>
<p><a href="http://weblogtoolscollection.com/archives/2010/02/25/passing-parameters-as-variables-vs-passing-parameters-as-an-array/" target="_blank">http://weblogtoolscollection.com/archives/2010/02/25/passing-parameters-as-variables-vs-passing-parameters-as-an-array/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2010/08/25/method-signatures-pass-values-as-individual-parameters-or-an-option-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wordpress wp_redirect() shows a blank page</title>
		<link>http://www.chrisshennan.com/2010/02/27/wordpress-wp_redirect-shows-a-blank-page/</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>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2010/02/27/wordpress-wp_redirect-shows-a-blank-page/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Raw SQL from Doctrine Query Object &#8211; Revised</title>
		<link>http://www.chrisshennan.com/2009/12/07/raw-sql-from-doctrine-query-object-revised/</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>
]]></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>
		</item>
		<item>
		<title>csNews Pro</title>
		<link>http://www.chrisshennan.com/2009/11/22/csnews-pro/</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>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/11/22/csnews-pro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TRUNCATE TABLE with Symfony and Doctrine</title>
		<link>http://www.chrisshennan.com/2009/11/20/truncate-table-with-symfony-and-doctrine/</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>
]]></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>
		</item>
		<item>
		<title>Raw SQL from a Doctrine Query Object</title>
		<link>http://www.chrisshennan.com/2009/09/22/raw-sql-from-a-doctrine-query-object/</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>
]]></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>
		</item>
		<item>
		<title>Why you should answer your own posts?</title>
		<link>http://www.chrisshennan.com/2009/08/24/why-you-should-answer-your-own-posts/</link>
		<comments>http://www.chrisshennan.com/2009/08/24/why-you-should-answer-your-own-posts/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 20:18:15 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=127</guid>
		<description><![CDATA[How many times have you searched for the answer to a problem in Google to find nothing but forums with people who have the same questions but no solutions posted even though the question was raised months, even years earlier?  
If you post a question and no-one managed to provide you with an answer [...]]]></description>
			<content:encoded><![CDATA[<p>How many times have you searched for the answer to a problem in Google to find nothing but forums with people who have the same questions but no solutions posted even though the question was raised months, even years earlier?  </p>
<p>If you post a question and no-one managed to provide you with an answer do you:-</p>
<ul>
<li>post up your solution when you&#8217;ve found it? or</li>
<li>simply forget about the post and leave everyone else to figure it out themselves too?</li>
</ul>
<p>Unfortunately there are a number of people in the latter category (myself included from time to time) and being a web developer means I run into this type of issue more than I would like but, I&#8217;ve recently come across yet another great reason why you should go back and answer your own question when you have managed to work out the answer.<br />
<span id="more-127"></span><br />
A few months ago I was working for <a href="http://www.alienationdigital.co.uk" target="_blank">Alienation Digital</a> in Glasgow and I had a problem with creating a <a href="http://forum.symfony-project.org/index.php/mv/tree/20144/76457/" target="_blank">custom validator using a callback in Symfony</a> and I posted the problem to the Symfony forums, and later, the solution I used to rectify the problem.</p>
<p>Fast forward a few months and you now find me working for <a href="http://www.line.uk.com" target="_blank">Line Digital</a> in Edinburgh and I&#8217;m now working on a new project which has a very similar problem.  Obviously I don&#8217;t have access to the code I wrote while at <a href="http://www.alienationdigital.co.uk" target="_blank">Alienation Digital</a> but unsurprisingly I had forgotten I have already solved this problem as it&#8217;s months since I had to last think about it.</p>
<p>So out comes Google again, I enter my search phrase and I am amazed that the first forum post (which resulted in the path to the solution) was my own post that I wrote while at <a href="http://www.alienationdigital.co.uk" target="_blank">Alienation Digital</a>.</p>
<p>So the moral of the story is to answer your own posts, even if you do end up feeling like you&#8217;re talking to yourself because you the next person your post helps out may be yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/08/24/why-you-should-answer-your-own-posts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Symfony &#8211; Does not have a registered handler</title>
		<link>http://www.chrisshennan.com/2009/08/02/symfony-does-not-have-a-registered-handler/</link>
		<comments>http://www.chrisshennan.com/2009/08/02/symfony-does-not-have-a-registered-handler/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 16:57:01 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[line digital]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=98</guid>
		<description><![CDATA[Last week I was working away in the office at Line Digital on our latest Symfony based project when our project started giving us a strange error similar to:-
Fatal error:  Uncaught exception &#8217;sfConfigurationException&#8217; with message &#8216;Configuration file &#38;quot;/usr/lib/php/symfony/config/config/core_compile.yml&#38;quot; does not have a registered handler.&#8217; in /usr/lib/php/symfony/config/sfConfigCache.class.php:101
Looking into this a little closer we found that [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I was working away in the office at <a title="Line Digital" href="http://www.line.uk.com" target="_blank">Line Digital</a> on our latest Symfony based project when our project started giving us a strange error similar to:-</p>
<blockquote><p>Fatal error:  Uncaught exception &#8217;sfConfigurationException&#8217; with message &#8216;Configuration file &amp;quot;/usr/lib/php/symfony/config/config/core_compile.yml&amp;quot; does not have a registered handler.&#8217; in /usr/lib/php/symfony/config/sfConfigCache.class.php:101</p></blockquote>
<p>Looking into this a little closer we found that the server had ran out of disk space so after making some space and using &#8220;symfony cc&#8221; to clear the cache we thought that this would have resolved the problem, however we continued to get the &#8220;does not havea  registered handler&#8221; message being presented.</p>
<p><span id="more-98"></span>In the end, we had to clear the cache manually with a command similar to:-</p>
<blockquote><p>rm -fr cache/*</p></blockquote>
<p>For some reason this seemed to work fine where as the &#8220;symfony cc&#8221; command didn&#8217;t work therefore the only conclusion that we could come up with is that when the server ran out of disk space it corrupted something in the symfony cache which either is not normally cleared with a &#8220;symfony cc&#8221; and as a result we needed to remove it completely so symfony could re-build it automatically.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/08/02/symfony-does-not-have-a-registered-handler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Month Names in PHP</title>
		<link>http://www.chrisshennan.com/2009/07/28/month-names-in-php/</link>
		<comments>http://www.chrisshennan.com/2009/07/28/month-names-in-php/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 21:13:25 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=83</guid>
		<description><![CDATA[One simple thing I keep having to do over and over again is to display the name of the month for a given date.  Normally I have opted to use the first solution that comes to mind which is creating an array with all the month names in it and then when I want to [...]]]></description>
			<content:encoded><![CDATA[<p>One simple thing I keep having to do over and over again is to display the name of the month for a given date.  Normally I have opted to use the first solution that comes to mind which is creating an array with all the month names in it and then when I want to retrieve the month name I just use</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$monthName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$aMonth</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$monthNum</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>However, when I wanted to use PHP to display the month name this time I wanted to see if there was a better solution.</p>
<p>The one I came across was posted on <a title="The Code Cookbook" href="http://code-cookbook.com/entry/80/php-month-number-to-month-name" target="_blank">The Code Cookbook</a> and was a simple 1 line statement which was great&#8230; simpler, neater and far more elegant than my usual method and it looked like</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$monthName</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;F&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$monthNum</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><span>Normally I would have been happy with this, however was needing to deal with a month drop down box which didn&#8217;t run from January to December but instead ran from November to April but this worked out to be rather simple too. </span></p>
<p><span id="more-83"></span>Using PHP to display the month names from November to April was achieved simply by using the above statement in a loop and my first attempt looked like this:-</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;F&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">11</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>As I was aware the months would be rolling over to the following year I have attempted to use the mod function to ensure the month values are valid.  The numbers for months, unlike days and years, run from 0 to 11 representing January to December respectively so the above loop works great, however it can be simplified yet again.</p>
<p>After one of my colleagues looked over this section of code they advised me that mktime will automatically round the date should you attempt to create an invalid date so the above loop can be simplifed to:-</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span><span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span>  <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;F&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">mktime</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$i</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">11</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>What I was expecting was:-</p>
<p>2009-11-01 = OK<br />
2009-12-01 = OK<br />
2009-13-01 = NOT OK</p>
<p>but instead the last of those 3 examples actually gave the value of 2010-01-01 which is a valid date and would mean that I would be able to display the month names November to April very very easily indeed!</p>
<p>Now that I&#8217;m aware of that I&#8217;ll not be going back to my old method for display month names in PHP!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/07/28/month-names-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento &#8211; Virtual Host Configuration Problems</title>
		<link>http://www.chrisshennan.com/2009/06/20/magento-virtual-host-configuration-problems/</link>
		<comments>http://www.chrisshennan.com/2009/06/20/magento-virtual-host-configuration-problems/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 15:29:33 +0000</pubDate>
		<dc:creator>Christopher Shennan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache configuration]]></category>
		<category><![CDATA[Magento]]></category>
		<category><![CDATA[vhost]]></category>
		<category><![CDATA[virtual host]]></category>

		<guid isPermaLink="false">http://www.chrisshennan.com/?p=72</guid>
		<description><![CDATA[A few weeks ago the company I work for was changing the server that several client sites are hosted on and this included a website built up using the eCommerce package magento.   All of the migrations went ahead without any problems with the exception of this magento site and it had a couple of [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago the company I work for was changing the server that several client sites are hosted on and this included a website built up using the eCommerce package <a href="http://www.magentocommerce.com/">magento</a>.   All of the migrations went ahead without any problems with the exception of this magento site and it had a couple of us stumped for quite a while.</p>
<h3>Process</h3>
<p>We followed the basic plan for the migration:-</p>
<ul>
<li>Copy magento files up to the new server</li>
<li>Backup the database on the old server and restore on the new server and set the MySQL user</li>
<li>Update the &#8220;web/unsecure/base_url&#8221; and &#8220;web/secure/base_url&#8221; keys within the core_config_data</li>
</ul>
<p>This seems to work well for almost everyone we found asking for migration help on the forums but did not work for us.  We even tried updating the /downloader/pear/pear.ini to ensure any additional modules downloaded via Magento Connect would install properly (I have since found out you can simply delete the pear.ini and Magento Connect will rebuild it with the correct paths!)<br />
<span id="more-72"></span></p>
<h3>Symtoms</h3>
<p>After performing the above steps the site out only partically work&#8230; You ccould browse the site, use the administration pages, add a simple product to the cart but you could <strong>not</strong> add a comfigurable product to the cart nor could you update the quantities of the items already in the cart.  As you were able to add some products and not others this left us quite confused.</p>
<p>After checking that the folder permissions were correct, session files were getting written and trying the migration on 2 or 3 different servers (all of which worked except the new server) one of our colleagues manage to isolate the issue as being a problem with the virtual host configuration for the magento site.  As this configuration worked on all the other servers we tried we didn&#8217;t suspect that would be a problem but the new server must have been configuration to be more secure than the other ones we have been testing the migration on.</p>
<h3>Solution</h3>
<p>This fix was really quite simple&#8230; all we had to do was add the following line into the magento sites virtual host configuration:-</p>
<blockquote><p>AllowOverride All</p></blockquote>
<p>Now everything runs fine&#8230; and everyone is happy (and now a little wiser) again!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chrisshennan.com/2009/06/20/magento-virtual-host-configuration-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
