<?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>Web Development &#38; Stuff</title>
	<atom:link href="http://web-development-blog.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://web-development-blog.co.uk</link>
	<description>Some interesting findings from web-dev land...</description>
	<lastBuildDate>Mon, 02 Apr 2012 15:10:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Multiple checkboxes automagically with CakePHP</title>
		<link>http://web-development-blog.co.uk/2012/04/02/multiple-checkboxes-automagically-with-cakephp/</link>
		<comments>http://web-development-blog.co.uk/2012/04/02/multiple-checkboxes-automagically-with-cakephp/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 15:09:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=500</guid>
		<description><![CDATA[For my own records: http://book.cakephp.org/1.3/view/1395/options-multiple
]]></description>
			<content:encoded><![CDATA[<p>For my own records: <a href="http://book.cakephp.org/1.3/view/1395/options-multiple">http://book.cakephp.org/1.3/view/1395/options-multiple</a></p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2012/04/02/multiple-checkboxes-automagically-with-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy way to render table calendar days HTML with PHP</title>
		<link>http://web-development-blog.co.uk/2012/02/28/easy-way-to-render-table-calendar-days-html-with-php/</link>
		<comments>http://web-development-blog.co.uk/2012/02/28/easy-way-to-render-table-calendar-days-html-with-php/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 12:50:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=489</guid>
		<description><![CDATA[If you have an array that represents the days in a month, ready to populate a HTML table, something like this:
1234567891011121314151617181920212223242526272829303132333435363738Array
&#40;
&#160; &#160; &#91;0&#93; =&#62; &#160; 
&#160; &#160; &#91;1&#93; =&#62; &#160; 
&#160; &#160; &#91;2&#93; =&#62; 1
&#160; &#160; &#91;3&#93; =&#62; 2
&#160; &#160; &#91;4&#93; =&#62; 3
&#160; &#160; &#91;5&#93; =&#62; 4 
&#160; &#160; &#91;6&#93; =&#62; 5 
&#160; &#160; &#91;7&#93; [...]]]></description>
			<content:encoded><![CDATA[<p>If you have an array that represents the days in a month, ready to populate a HTML table, something like this:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%;height:300px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">Array</span><br />
<span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">1</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">2</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">4</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">3</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">5</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">4</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">6</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">5</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">7</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">6</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">8</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">7</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">9</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">8</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">10</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">9</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">11</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">10</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">12</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">11</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">13</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">12</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">14</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">13</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">15</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">14</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">16</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">15</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">17</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">16</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">18</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">17</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">19</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">18</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">20</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">19</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">21</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">20</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">22</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">21</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">23</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">22</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">24</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">23</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">25</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">24</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">26</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">25</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">27</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">26</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">28</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">27</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">29</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">28</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">30</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">29</span> <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">31</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">32</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">33</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> &nbsp; <br />
&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">34</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> &nbsp; <br />
<span class="br0">&#41;</span></div></td></tr></tbody></table></div>
<p>This is a nice way IMO to render (in a view/template) the days markup inside the tbody tag:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy1">&lt;?</span> <span class="re0">$daysInWeek</span> <span class="sy0">=</span> <span class="nu0">7</span> <span class="sy1">?&gt;</span><br />
<br />
<span class="sy1">&lt;?</span> <span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$days</span> <span class="kw1">as</span> <span class="re0">$key</span> <span class="sy0">=&gt;</span> <span class="re0">$day</span><span class="br0">&#41;</span><span class="sy0">:</span> <span class="sy1">?&gt;</span><br />
&nbsp; &nbsp; <span class="sy1">&lt;?</span> <span class="re0">$rows</span><span class="br0">&#91;</span><span class="re0">$key</span> <span class="sy0">%</span> <span class="re0">$daysInWeek</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="sy0">!</span><span class="kw3">empty</span><span class="br0">&#40;</span><span class="re0">$day</span><span class="br0">&#41;</span> ? <span class="re0">$day</span> <span class="sy0">:</span> <span class="st_h">'&amp;nbsp;'</span> &nbsp;<span class="sy1">?&gt;</span><br />
<span class="sy1">&lt;?</span> <span class="kw1">endforeach</span> <span class="sy1">?&gt;</span><br />
<br />
&lt;tbody&gt;<br />
<br />
&nbsp; &nbsp; <span class="sy1">&lt;?</span> <span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$rows</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> <span class="kw1">as</span> <span class="re0">$k1</span> <span class="sy0">=&gt;</span> <span class="re0">$day</span> <span class="br0">&#41;</span><span class="sy0">:</span> <span class="sy1">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sy1">&lt;?</span> <span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$rows</span> <span class="kw1">as</span> <span class="re0">$k2</span> <span class="sy0">=&gt;</span> <span class="re0">$r</span><span class="br0">&#41;</span><span class="sy0">:</span> <span class="sy1">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<span class="sy1">&lt;?=</span> <span class="re0">$rows</span><span class="br0">&#91;</span><span class="re0">$k2</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="re0">$k1</span> <span class="sy0">%</span> <span class="re0">$daysInWeek</span><span class="br0">&#93;</span> <span class="sy1">?&gt;</span>&lt;/td&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sy1">&lt;?</span> <span class="kw1">endforeach</span> <span class="sy1">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />
&nbsp; &nbsp; <span class="sy1">&lt;?</span> <span class="kw1">endforeach</span> <span class="sy1">?&gt;</span><br />
<br />
&lt;/tbody&gt;</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2012/02/28/easy-way-to-render-table-calendar-days-html-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP 1.3 Custom validation rule error &#8211; preg_match() Delimiter must not be alphanumeric or backslash</title>
		<link>http://web-development-blog.co.uk/2011/12/22/cakephp-1-3-custom-validation-rule-error-preg_match-delimiter-must-not-be-alphanumeric-or-backslash/</link>
		<comments>http://web-development-blog.co.uk/2011/12/22/cakephp-1-3-custom-validation-rule-error-preg_match-delimiter-must-not-be-alphanumeric-or-backslash/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 15:35:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=485</guid>
		<description><![CDATA[If you get this error:
1Warning: Warning &#40;2&#41;: preg_match&#40;&#41; &#91;&#60;a href='function.preg-match'&#62;function.preg-match&#60;/a&#62;&#93;: Delimiter must not be alphanumeric or backslash in &#91;/var/www/vhosts/h2oservices.com/httpdocs/cake/libs/model/model.php, line 2611&#93;
When trying to use a custom validation rule, make sure the method visibility is set to public.
So this should work:
123public function myCustomValidateRule&#40;&#41;&#123;
&#160; &#160; // Custom validation code
&#125;
It seems protected visibility works on some versions of [...]]]></description>
			<content:encoded><![CDATA[<p>If you get this error:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace">Warning<span class="sy0">:</span> Warning <span class="br0">&#40;</span><span class="nu0">2</span><span class="br0">&#41;</span><span class="sy0">:</span> <span class="kw3">preg_match</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#91;</span><span class="sy0">&lt;</span>a href<span class="sy0">=</span><span class="st_h">'function.preg-match'</span><span class="sy0">&gt;</span>function<span class="sy0">.</span>preg<span class="sy0">-</span>match<span class="sy0">&lt;/</span>a<span class="sy0">&gt;</span><span class="br0">&#93;</span><span class="sy0">:</span> Delimiter must not be alphanumeric or backslash in <span class="br0">&#91;</span><span class="sy0">/</span><span class="kw2">var</span><span class="sy0">/</span>www<span class="sy0">/</span>vhosts<span class="sy0">/</span>h2oservices<span class="sy0">.</span>com<span class="sy0">/</span>httpdocs<span class="sy0">/</span>cake<span class="sy0">/</span>libs<span class="sy0">/</span>model<span class="sy0">/</span>model<span class="sy0">.</span>php<span class="sy0">,</span> line <span class="nu0">2611</span><span class="br0">&#93;</span></div></td></tr></tbody></table></div>
<p>When trying to use a custom validation rule, make sure the method visibility is set to public.</p>
<p>So this should work:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">public</span> <span class="kw2">function</span> myCustomValidateRule<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">// Custom validation code</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>It seems protected visibility works on some versions of PHP (5.2.11 tested and working) and not others.</p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/12/22/cakephp-1-3-custom-validation-rule-error-preg_match-delimiter-must-not-be-alphanumeric-or-backslash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ternary in PHP Heredoc</title>
		<link>http://web-development-blog.co.uk/2011/12/15/ternary-in-php-heredoc/</link>
		<comments>http://web-development-blog.co.uk/2011/12/15/ternary-in-php-heredoc/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 15:26:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=473</guid>
		<description><![CDATA[It can&#8217;t be done using the normal Ternary operator but you can emulate it with:
12345678910111213// So instead of:

$str = &#60;&#60;&#60;HTML
{$a ? 1 : 2}
HTML;

// You can do:

$values = array&#40;'1', '2'&#41;;

$str = &#60;&#60;&#60;HTML
{$values[$a]}
HTML;
]]></description>
			<content:encoded><![CDATA[<p>It can&#8217;t be done using the normal Ternary operator but you can emulate it with:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co1">// So instead of:</span><br />
<br />
<span class="re0">$str</span> <span class="sy0">=</span> <span class="co3">&lt;&lt;&lt;HTML<br />
{$a ? 1 : 2}<br />
HTML</span><span class="sy0">;</span><br />
<br />
<span class="co1">// You can do:</span><br />
<br />
<span class="re0">$values</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="st_h">'1'</span><span class="sy0">,</span> <span class="st_h">'2'</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="re0">$str</span> <span class="sy0">=</span> <span class="co3">&lt;&lt;&lt;HTML<br />
{$values[$a]}<br />
HTML</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/12/15/ternary-in-php-heredoc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP large file upload fails error code 7 (Apache)</title>
		<link>http://web-development-blog.co.uk/2011/11/08/php-large-file-upload-fails-error-code-7-apache/</link>
		<comments>http://web-development-blog.co.uk/2011/11/08/php-large-file-upload-fails-error-code-7-apache/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 09:29:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=469</guid>
		<description><![CDATA[Don&#8217;t forget kids to check the size of the tmp partition if you are having issues uploading large files with PHP.
After setting all the usual configuration directives (upload_max_filesize, post_max_size etc) uploads were still failing for me returning error code 7.
After poking around on the Debian VPS for a while I realised the /tmp partition was [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t forget kids to check the size of the tmp partition if you are having issues uploading large files with PHP.</p>
<p>After setting all the usual configuration directives (upload_max_filesize, post_max_size etc) uploads were still failing for me returning error code 7.</p>
<p>After poking around on the Debian VPS for a while I realised the /tmp partition was 128mb!!</p>
<p>Luckily you can set the path for file uploads using the following directive:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace">upload_tmp_dir <span class="sy0">=</span> <span class="sy0">/</span>path<span class="sy0">/</span>to<span class="sy0">/</span>somewhere<span class="sy0">/</span>with<span class="sy0">/</span>some<span class="sy0">/</span>disk<span class="sy0">/</span>space</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/11/08/php-large-file-upload-fails-error-code-7-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtual/non existent model fields using CakePHP Security Component</title>
		<link>http://web-development-blog.co.uk/2011/10/13/virtualnon-existent-model-fields-using-cakephp-security-component/</link>
		<comments>http://web-development-blog.co.uk/2011/10/13/virtualnon-existent-model-fields-using-cakephp-security-component/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 08:07:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=463</guid>
		<description><![CDATA[If you have fields that don&#8217;t exist in your table schema and you want to submit those to an action that is protected by the Security component. You can tell the component to ignore (and therefore not black hole/404 your request) the field(s) using its $disabledFields attribute.
In this example I&#8217;m ignoring the security_code (captcha) field, [...]]]></description>
			<content:encoded><![CDATA[<p>If you have fields that don&#8217;t exist in your table schema and you want to submit those to an action that is protected by the Security component. You can tell the component to ignore (and therefore not black hole/404 your request) the field(s) using its $disabledFields attribute.</p>
<p>In this example I&#8217;m ignoring the security_code (captcha) field, which obviously I don&#8217;t store anywhere in the database table:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">Security</span><span class="sy0">-&gt;</span><span class="me1">disabledFields</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'Enquiry.security_code'</span><br />
<span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/10/13/virtualnon-existent-model-fields-using-cakephp-security-component/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using CakePHP log() in a vendor class</title>
		<link>http://web-development-blog.co.uk/2011/07/20/using-cakephp-log-in-a-vendor-class/</link>
		<comments>http://web-development-blog.co.uk/2011/07/20/using-cakephp-log-in-a-vendor-class/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 10:48:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=452</guid>
		<description><![CDATA[The proper way to do this is with a static call to Debugger:
1Debugger::log&#40;$output&#41;;
]]></description>
			<content:encoded><![CDATA[<p>The proper way to do this is with a static call to Debugger:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace">Debugger<span class="sy0">::</span><span class="kw3">log</span><span class="br0">&#40;</span><span class="re0">$output</span><span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/07/20/using-cakephp-log-in-a-vendor-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux batch file rename</title>
		<link>http://web-development-blog.co.uk/2011/05/24/linux-batch-file-rename/</link>
		<comments>http://web-development-blog.co.uk/2011/05/24/linux-batch-file-rename/#comments</comments>
		<pubDate>Tue, 24 May 2011 13:59:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux servers]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=448</guid>
		<description><![CDATA[For my own records. Batch file rename using shell:
123Rename all jpg files that contain the string 19_ and replace it with 28_

for file in *.jpg ; do mv $file `echo $file &#124; sed 's/19_/28_/g'` ; done
]]></description>
			<content:encoded><![CDATA[<p>For my own records. Batch file rename using shell:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">Rename</span> all jpg files that contain the string <span class="nu0">19</span>_ and replace it with <span class="nu0">28</span>_<br />
<br />
<span class="kw1">for</span> <span class="kw3">file</span> in <span class="sy0">*.</span>jpg <span class="sy0">;</span> <span class="kw1">do</span> mv <span class="re0">$file</span> `<span class="kw3">echo</span> <span class="re0">$file</span> <span class="sy0">|</span> sed <span class="st_h">'s/19_/28_/g'</span>` <span class="sy0">;</span> done</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/05/24/linux-batch-file-rename/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP virtual field count another model/table</title>
		<link>http://web-development-blog.co.uk/2011/03/08/cakephp-virtual-field-count-another-modeltable/</link>
		<comments>http://web-development-blog.co.uk/2011/03/08/cakephp-virtual-field-count-another-modeltable/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 10:37:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Web development]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=428</guid>
		<description><![CDATA[Just managed to count another table using a model virtual field, obviously preserving the association with the sub query conditions.
So in my ProductTemplate model I have this:
123var $virtualFields = array&#40;
&#160; &#160; 'page_count' =&#62; 'SELECT COUNT(*) FROM pages as Page WHERE Page.product_template_id = ProductTemplate.id'
&#160; &#41;;
The nice thing about this is you can use the field with [...]]]></description>
			<content:encoded><![CDATA[<p>Just managed to count another table using a <a href="http://book.cakephp.org/view/1608/Virtual-fields">model virtual field</a>, obviously preserving the association with the sub query conditions.</p>
<p>So in my ProductTemplate model I have this:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">var</span> <span class="re0">$virtualFields</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="st_h">'page_count'</span> <span class="sy0">=&gt;</span> <span class="st_h">'SELECT COUNT(*) FROM pages as Page WHERE Page.product_template_id = ProductTemplate.id'</span><br />
&nbsp; <span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
<p>The nice thing about this is you can use the field with the CakePHP Model::find ordering and with the pagination component.</p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2011/03/08/cakephp-virtual-field-count-another-modeltable/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Saving CakePHP HABTM models with join table data</title>
		<link>http://web-development-blog.co.uk/2010/10/25/saving-cakephp-habtm-models-with-join-table-data/</link>
		<comments>http://web-development-blog.co.uk/2010/10/25/saving-cakephp-habtm-models-with-join-table-data/#comments</comments>
		<pubDate>Mon, 25 Oct 2010 18:16:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://web-development-blog.co.uk/?p=402</guid>
		<description><![CDATA[You can save has and belongs to many models in CakePHP (v1.3.4) whilst adding additional data to the join table, in a single operation.
In this example I&#8217;m saving Users that HABTM Videos. The users_videos join table has an order column. 
Firstly add the &#8216;with&#8217; parameter to the join, you can add the &#8216;order&#8217; parameter too [...]]]></description>
			<content:encoded><![CDATA[<p>You can save has and belongs to many models in CakePHP (v1.3.4) whilst adding additional data to the join table, in a single operation.</p>
<p>In this example I&#8217;m saving Users that HABTM Videos. The users_videos join table has an order column. </p>
<p>Firstly add the &#8216;with&#8217; parameter to the join, you can add the &#8216;order&#8217; parameter too if it makes sense in your context:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">class</span> User <span class="kw2">extends</span> AppModel <span class="br0">&#123;</span><br />
&nbsp; <br />
&nbsp; <span class="kw2">public</span> <span class="re0">$hasAndBelongsToMany</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; &nbsp; <span class="st_h">'Video'</span> <span class="sy0">=&gt;</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; <span class="st_h">'with'</span> <span class="sy0">=&gt;</span> <span class="st_h">'UsersVideo'</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; <span class="st_h">'order'</span> <span class="sy0">=&gt;</span> <span class="st_h">'UsersVideo.order'</span><br />
&nbsp; &nbsp; <span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>Make sure you do a $model->saveAll() in the controller:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">User</span><span class="sy0">-&gt;</span><span class="me1">saveAll</span><span class="br0">&#40;</span><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">data</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// Success message</span><br />
&nbsp; <span class="co1">// Redirect &nbsp; &nbsp; </span><br />
<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// Error message</span><br />
<span class="br0">&#125;</span></div></td></tr></tbody></table></div>
<p>The trick is in the naming of the form input elements. The format is Video.X.UsersVideo.field_name.</p>
<p>Here&#8217;s an example:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy1">&lt;?=</span> <span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">input</span><span class="br0">&#40;</span><span class="st_h">'Video.id'</span><span class="br0">&#41;</span> <span class="sy1">?&gt;</span><br />
<br />
<span class="sy1">&lt;?=</span> <span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">input</span><span class="br0">&#40;</span><span class="st_h">'Video.0.UsersVideo.video_id'</span><span class="sy0">,</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'select'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'options'</span> <span class="sy0">=&gt;</span> <span class="re0">$videos</span><br />
<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy1">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; <br />
<span class="sy1">&lt;?=</span> <span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">input</span><span class="br0">&#40;</span><span class="st_h">'Video.0.UsersVideo.order'</span><span class="sy0">,</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'select'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'options'</span> <span class="sy0">=&gt;</span> <span class="kw3">range</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="sy0">,</span> <span class="kw3">count</span><span class="br0">&#40;</span><span class="re0">$videos</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy1">?&gt;</span><br />
<br />
<span class="sy1">&lt;?=</span> <span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">input</span><span class="br0">&#40;</span><span class="st_h">'Video.0.UsersVideo.user_id'</span><span class="sy0">,</span> <span class="kw3">array</span><span class="br0">&#40;</span><br />
&nbsp; <span class="st_h">'type'</span> <span class="sy0">=&gt;</span> <span class="st_h">'hidden'</span><span class="sy0">,</span><br />
&nbsp; <span class="st_h">'value'</span> <span class="sy0">=&gt;</span> <span class="re0">$user</span><span class="br0">&#91;</span><span class="st_h">'User'</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">'id'</span><span class="br0">&#93;</span><br />
<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="sy1">?&gt;</span></div></td></tr></tbody></table></div>
<p>Which outputs:</p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:100%"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="br0">&#91;</span>User<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="kw3">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>id<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">3</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><br />
<span class="br0">&#91;</span>Video<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="kw3">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="kw3">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>UsersVideo<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="kw3">Array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>video_id<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">9</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>order<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span>user_id<span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="nu0">3</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span></div></td></tr></tbody></table></div>
<p>This will add a record to the join table with the order value.</p>
<p>Obviously you can expand on this to save more users_videos records during the same saveAll call.</p>
]]></content:encoded>
			<wfw:commentRss>http://web-development-blog.co.uk/2010/10/25/saving-cakephp-habtm-models-with-join-table-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

