<?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>@TheKeyboard &#187; CakePHP</title>
	<atom:link href="http://www.littlehart.net/atthekeyboard/category/cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.littlehart.net/atthekeyboard</link>
	<description>Facebook should&#039;ve be written in unicornSchemaLang, because everyone *knows* that PHP is no good for anything, right?</description>
	<lastBuildDate>Fri, 12 Mar 2010 22:00:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
			<item>
		<title>What Is Really Considered Documentation?</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/07/22/what-is-really-considered-documentation/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2008/07/22/what-is-really-considered-documentation/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 02:46:34 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Chris' Brain]]></category>
		<category><![CDATA[documentation]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=285</guid>
		<description><![CDATA[
I struggled to come up with a good name for this blog post, and have totally failed, but give this article a chance.  Or maybe you&#8217;re here by accident thanks to a weird google search.

As a committed user of open source technologies, the difference between me using something and not using something is the [...]]]></description>
			<content:encoded><![CDATA[<p>
I struggled to come up with a good name for this blog post, and have totally failed, but give this article a chance.  Or maybe you&#8217;re here by accident thanks to a weird google search.
</p>
<p>As a committed user of open source technologies, the difference between me using something and not using something is the documentation.  Is there documentation for it?  Is it easy to find?  Does it answer my questions?  Is there someone I can call an idiot if I disagree with the level of documentation?  These are all very important questions.
</p>
<p>My involvement with <a href="http://cakephp.org">CakePHP</a> has opened my eyes in terms of what people consider documentation.  Me, I&#8217;m the type who learns from examples that come with explanations.  While API documentation is great, it only becomes useful to me once *I* can figure out how to do something useful with this new technology.  I see people on the mailing list for Cake asking for the source code to a sample application, which I immediately file away in my head as &#8220;looking for answer to their homework&#8221;, and move on.  Maybe that&#8217;s unfair, but it&#8217;s more a reflection of the fact that I tend not to learn anything from having the source code for an application.  I learn by getting in there and DOING SOMETHING and figuring out why this goddamn thing is not behaving properly and who do I know who can help me with this problem etc.  Learning by mooching, I call it.
</p>
<p>
So, back to CakePHP.  CakePHP had acquired the reputation that the documentation for it sucked.  While I did not share that opinion, I can see why people say that.  Because most coders are lazy.  Seriously.  They want solutions handed to them in a form that they can just drop into their application and then get onto the next problem.  There are definitely times when I wish someone else could just write this goddamn &#8220;alter the football game stats form dynamically via Ajax and send the results to the XML database&#8221; code for me.  Inevitably, I build the code up from an example stolen via Google into something that both works and that I understand fully.  However, most of the time I am content to figure stuff out on my own and ask for help only when stuck.  I&#8217;m not lazy, but maybe I&#8217;m suffering from a bit of the <a href="http://en.wikipedia.org/wiki/Lake_Wobegon_effect">Lake Woebegon effect</a>.
</p>
<p>So, things are much better in terms of documentation for CakePHP.  Whereas we used to have a manual that only covered 1.1, we now have the amazing <a href="http://book.cakephp.org">CakePHP cookbook</a> that covers both 1.1 and 1.2.  If that&#8217;s not enough, well, you might actually have to do a little thing I like to call &#8220;research&#8221;.  This gets us to the point of this blog posting.  Sometimes you have to stop being lazy and actually think about where you could find an answer.
</p>
<p>
There are no shortage of blogs that talk about CakePHP.  Some of them are even good.  Maybe you like the code examples I put up here.  People seem to like them enough to comment, so maybe I&#8217;m doing something right.  Google is your friend to track down blogs that have exactly the type of information that you need:  small examples with explanations about how they work.
</p>
<p>
The CakePHP mailing list is done via Google Groups, so all those posts where I make fun of people for no reason other than my poor self-esteem can be found with a few keywords.  But there are a lot of great tips on how to accomplish things using Cake, so a search of the google group will find lots of good information.
</p>
<p>
The <a href="http://bakery.cakephp.org">Bakery</a> is another good source of CakePHP info, consisting of all sorts of small articles along with comments.  It has a search function as well, but could easily be considered YACB (Yet Another Cake Blog).  Again, perfect for people with the same learning style as me:  short examples with explanations of how it was done.
</p>
<p>
Finally, we come to one of the more unorthodox documentation sources:  the unit tests for CakePHP.  CakePHP has some really good unit test coverage, although I sometimes wonder if you can really say that a piece of code works properly if it passes all the unit tests associated with it.  This is by no means a phenomenon limited to CakePHP, it happens everywhere there are unit tests.  Sometimes you can&#8217;t figure out a test that makes something break.  It happens, so please do not misinterpret my thoughts on this.  Unit tests are good, and the amount of tests that CakePHP has in place is awesome and perfect example of a cohesive development team.  Automated testing is a goal worth striving for, don&#8217;t let anyone else tell you otherwise.  I&#8217;m in the early phases of automated testing for a work project on the integration side of things because I&#8217;m tired of always running through the same damn tests by hand all the time to make sure something that I wrote didn&#8217;t break things.  Tips on what good browser-based solutions are out there would be appreciated.  Other than telling me to use Selenium.  A solution that is tailored to the <a href="http://codeigniter.com">framework I have been forced to use</a> would be even better.
</p>
<p>
Okay, back on topic.  Since the unit tests cover so much of what CakePHP can do, what better way to see examples of how to actual do things?  My work on fiddling around with new console functionality showed me that I had no idea of how to create unit tests for my console work.  That led to discussions with people on the best way to do testing of console functionality.  Which leads to changes in the console code itself to make it easier to test certain things.  But at least when I&#8217;m ready to get back to doing that console work I can see if doing testing for it has become easier.
</p>
<p>
So, having been told all the stuff above, how can anyone who is not simply lazy say that the documentation for CakePHP sucks?!?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2008/07/22/what-is-really-considered-documentation/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>CakePHP and the iPhone</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/06/13/cakephp-and-the-iphone/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2008/06/13/cakephp-and-the-iphone/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 19:07:04 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=278</guid>
		<description><![CDATA[I lost my cellphone last night, which sucks because the phone I want isn&#8217;t going to be available until July 11th.  I&#8217;ll get a loaner phone until then, but it is exciting times to be a web developer.  Why?  Because the introduction of the iPhone there is a renewed interest in web [...]]]></description>
			<content:encoded><![CDATA[<p>I lost my cellphone last night, which sucks because the phone I want isn&#8217;t going to be available until July 11th.  I&#8217;ll get a loaner phone until then, but it is exciting times to be a web developer.  Why?  Because the introduction of the iPhone there is a renewed interest in web sites that cope well with mobile browsing.  I&#8217;m working on an app that is perfect for mobile browsing, but that is still down the road.</p>
<p>
Anyhow, I saw a post the other day showing how to create an <a href="http://www.symfony-project.org/blog/2008/06/09/how-to-create-an-optimized-version-of-your-website-for-the-iphone-in-symfony-1-1">iPhone-optimized version of your Symfony app</a>.  Yawn.  Cake <a href="http://bakery.cakephp.org/articles/view/building-an-iphone-app-in-a-day">had that a year ago.</a>.  No code provided *but* the article does tell you exactly how he did it.
</p>
<p>
But that&#8217;s really the key here.  You don&#8217;t need to do anything special to make a web-based app in CakePHP that will work nicely on your iPhone.  Contrast that to all the stuff I see in that article that you need to do.  Off the top of my head, it seems to me the best way to do it is:</p>
<ul>
<li>create CSS and layouts for regular and iPhone versions of your application</li>
<li>do a check in your beforeFilter() method where you check the User-Agent</li>
<li>pass that info to your actions, and render whichever layout+CSS you need</li>
</ul>
<p>Compare the Symfony article to the CakePHP article plus my notes, and let me know what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2008/06/13/cakephp-and-the-iphone/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>CakePHP Application Deployment: RFC</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/05/16/cakephp-application-deployment-rfc/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2008/05/16/cakephp-application-deployment-rfc/#comments</comments>
		<pubDate>Fri, 16 May 2008 18:05:22 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[RFC]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=273</guid>
		<description><![CDATA[A co-worker of mine always complains that people don&#8217;t read the RFC that covers a topic related to making their own stuff work with our stuff.  He&#8217;s old sk00l like that.  Although my co-worker is a tad out-of-touch with the realities of programming these days (as in the amount of people who actually [...]]]></description>
			<content:encoded><![CDATA[<p>A co-worker of mine always complains that people don&#8217;t read the <a href="http://en.wikipedia.org/wiki/Request_for_Comments">RFC</a> that covers a topic related to making their own stuff work with our stuff.  He&#8217;s old sk00l like that.  Although my co-worker is a tad out-of-touch with the realities of programming these days (as in the amount of people who actually read the RFC when they can simply use someone else&#8217;s library / module / function / application is very small), I thought I would at least adhere to some semblance of standards and do a blog posting about my plans for making CakePHP application deployment easier.
</p>
<p>
While I really prefer to use <a href="http://capify.org">tools like this</a> for deployment, I understand that not everyone wants to mess with standalone programs and configuration files.  I&#8217;ve been asked before about Cake-specific deployment techniques, so I figure the easiest way is to see about adding a task to the Cake console.  Let&#8217;s call this &#8216;cake deploy&#8217;.
</p>
<p>
As I <a href="http://groups.google.com/group/cake-php/browse_thread/thread/ea4e5ec768c8d95a#">explained on the mailing list</a> I am looking for opinions on what sort of things should be part of the &#8216;cake deploy&#8217; task.  Right now, my thoughts are as follows:</p>
<ul>
<li><i>cake deploy config</i></li>
<p> &#8211; setup and edit configuration parameters.  Initially I thought of setting things like transport method (ssh, ftp), logins and passwords, remote location, source directory, and destination directory.  The configuration file would be stored locally in APP/config</p>
<li><i>cake deploy</i> &#8211; seems pretty self-explanatory to me.</li>
</ul>
<p>
In the RFC thread on the CakePHP mailing list, someone mentioned they&#8217;d like to see rsync, but I&#8217;m trying to avoid having to external programs required to make the deployment work.  Or, at least, use as few as possible.  Anyhow, if you have any thoughts on this feel free to add them to the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2008/05/16/cakephp-application-deployment-rfc/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>New CakePHP 1.2 Release Coming</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/05/13/new-cakephp-12-release-coming/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2008/05/13/new-cakephp-12-release-coming/#comments</comments>
		<pubDate>Tue, 13 May 2008 21:16:53 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=272</guid>
		<description><![CDATA[I&#8217;m certainly not the only person who has been blogging about this, but I thought I&#8217;d mention that a feature freeze is coming up for the next CakePHP 1.2 release, codenamed &#8216;DV&#8217;.  My very modest contribution this time around is a patch to fix a problem with running &#8216;cake bake&#8217; on Windows, where it [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m certainly not the only person who has been blogging about this, but I thought I&#8217;d mention that a feature freeze is coming up for the next CakePHP 1.2 release, codenamed &#8216;DV&#8217;.  My very modest contribution this time around is a patch to fix a problem with running &#8216;cake bake&#8217; on Windows, where it was mangling the app path that a user would enter.  <a href="https://trac.cakephp.org/ticket/4495">Ticket 4495</a> if anyone is interested.
</p>
<p>
Anyhow, anyone who uses CakePHP or wants to help out can definitely get involved in the process by:</p>
<ul>
<li>Entering bugs into CakePHP&#8217;s trac if they don&#8217;t see them in there</li>
<li>Contributing tests and/or patches for existing bugs</li>
<li>Testing out the bleeding-edge versions of CakePHP that you can get from the SVN repository</li>
</ul>
<p>
There has been a lot of debate on the mailing list about both the direction of the project and the attitude of people on the mailing list.  Well, as one of the people who gets to be involved in both sides (albeit a minor role in terms of contributing code) I can tell you that the project will continue moving forward, building on all the traction CakePHP has gotten.  Maybe 1.2 has dragged on for a while, but isn&#8217;t that just a number anyway?  Would people be reacting if it was Cake 1.7.2 or something like that?
</p>
<p>What people don&#8217;t always see is the amount of work that goes into CakePHP by developers.  Every morning when I log into my account on my MacBook, I update my copy of CakePHP from SVN.  99.999% of the time there is an update.  These days, tests are being written like crazy and <a href="http://debuggable.com/posts/code-coverage-analysis-soon-in-cakephp---test-how-well-you-test:4814f6a0-fe60-4f50-be0b-07194834cda3">Tim&#8217;s awesome work in creating code coverage information</a> and those things can only help the project as a whole get better.  These are exciting times for anyone connected to the project, no doubt about that.  No amount of CakePHP haters (you know who you are) are going to change that.
</p>
<p>
Secondly, people have to understand that a mailing list full of a lot of technical, highly-skilled people is not a friendly place for beginners.  Sad, but true.  I have answered many questions on the mailing list, some of them properly and some of them, well, let&#8217;s just say my nickname of GrumpyCanuck has been well-placed.  Can we all be civil?  Probably not.  Should we be civil?  Maybe.  I think anyone who doesn&#8217;t understand the dynamics of the CakePHP list itself should go and read <a href="http://www.catb.org/~esr/faqs/smart-questions.html">this</a>.  Forewarned is forearmed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2008/05/13/new-cakephp-12-release-coming/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Custom CakePHP 1.2 Pagination Queries</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/03/04/custom-cakephp-12-pagination-queries/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2008/03/04/custom-cakephp-12-pagination-queries/#comments</comments>
		<pubDate>Wed, 05 Mar 2008 03:29:24 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[pagination]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/03/04/custom-cakephp-12-pagination-queries/</guid>
		<description><![CDATA[
(Note: I will be cross-posting a version of this to the CakePHP Cookbook within a day or two).


As amazing as the built-in CakePHP pagination helper is, sometimes you have to create your own custom queries for data you wish to paginate.  For the simulation baseball league site I wanted to be create an admin [...]]]></description>
			<content:encoded><![CDATA[<p>
(Note: I will be cross-posting a version of this to <a href='http://book.cakephp.org'>the CakePHP Cookbook</a> within a day or two).
</p>
<p>
As amazing as the built-in CakePHP pagination helper is, sometimes you have to create your own custom queries for data you wish to paginate.  For <a href='http://www.ibl.org'>the simulation baseball league site</a> I wanted to be create an admin area where I could paginate through the series instead of individual games.  It took some digging around with google, but I found some info in a thread (thanks to <a href='http://www.3hndesigns.com/'>Baz</a> for contributing that tidbit to the thread) on how to do just that.
</p>
<p>
Okay, so it turns out that the paginate() method that is used to generate the data that you (oddly enough) paginate through takes the same arguments as Model::findAll().  So, if you want to use your own query, you simply create a 'paginate' method for your model.  In my case, I needed a query that would group things together (because a 'series' is simply a collection of all games between two teams in a particular week).  The query stuff I did is ugly because there currently is no support 'group by' in CakePHP (although that would be a very interesting project to tackle).  So, here's what I did:
</p>
<div class="igBar"><span id="lphp-3"><a href="#" onclick="javascript:showPlainTxt('php-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-3">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * Custom paginate method</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> paginate<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$conditions</span>, <span style="color:#0000FF;">$fields</span>, <span style="color:#0000FF;">$order</span>, <span style="color:#0000FF;">$limit</span>, <span style="color:#0000FF;">$page</span> = <span style="color:#CC66CC;color:#800000;">1</span>, <span style="color:#0000FF;">$recursive</span> = <span style="color:#000000; font-weight:bold;">null</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$conditions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> =<span style="color:#FF0000;">"1 = 1 GROUP BY week, away_team_id, home_team_id"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$recursive</span> = -<span style="color:#CC66CC;color:#800000;">1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$fields</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'week'</span>, <span style="color:#FF0000;">'away_team_id'</span>, <span style="color:#FF0000;">'home_team_id'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$params</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'conditions'</span> =&gt; <span style="color:#0000FF;">$conditions</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'recursive'</span> =&gt; <span style="color:#0000FF;">$recursive</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'fields'</span> =&gt; <span style="color:#0000FF;">$fields</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'order'</span> =&gt; <span style="color:#0000FF;">$order</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'limit'</span> =&gt; <span style="color:#0000FF;">$limit</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'page'</span> =&gt; <span style="color:#0000FF;">$page</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color:#616100;">return</span> <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'all'</span>, <span style="color:#0000FF;">$params</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>
So, that's the first part of the custom query stuff taken care off.  Next, I needed to be able to properly count the number of 'series' so that the numbers (you know, that stuff that says 'page 7 of 23') come out properly.  Again, you can override the paginateCount() method if you need to.  It uses the same parameters as Model::findCount().  Now, the custom query I'm using below is Postgres-specific, so YMMV:
</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showPlainTxt('php-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> * Custom paginateCount method</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">function</span> paginateCount<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$conditions</span> = <span style="color:#000000; font-weight:bold;">null</span>, <span style="color:#0000FF;">$recursive</span> = <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"SELECT DISTINCT ON(week, home_team_id, away_team_id) week, home_team_id, away_team_id FROM games"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">recursive</span> = <span style="color:#0000FF;">$recursive</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF;">$results</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">query</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#616100;">return</span> <a href="http://www.php.net/count"><span style="color:#000066;">count</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$results</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>
So there you have it.  Hope this helps out anyone who's been trying to figure out how to use custom queries with their pagination.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2008/03/04/custom-cakephp-12-pagination-queries/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Cooking Up Some Cake</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/02/18/cooking-up-some-cake/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2008/02/18/cooking-up-some-cake/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 15:15:38 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Cookbook]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/02/18/cooking-up-some-cake/</guid>
		<description><![CDATA[
Of all the people in the CakePHP community that I have come across, none suffers from a lack of respect more than John David Anderson, more commonly known as _psychic_ on IRC.  Why do I say this?  John heads the CakePHP documentation project, a thankless task that seems only to exist so unimaginative [...]]]></description>
			<content:encoded><![CDATA[<p>
Of all the people in the <a href="http://www.cakephp.org">CakePHP</a> community that I have come across, none suffers from a lack of respect more than John David Anderson, more commonly known as _psychic_ on IRC.  Why do I say this?  John heads the CakePHP documentation project, a thankless task that seems only to exist so unimaginative people can complain that there is no documentation for CakePHP.  If I had a dollar for every person on the CakePHP mailing list who seems to either not understand how to use Google or how to look at someone else's PHP code to figure out how something works, I could retire and blog full time.
</p>
<p>
But I digress.  With a ton of help from Andy Dawson (AD7Six) the documentation for CakePHP 1.2 has moved forward immensely with the unveiling of the <a href="http://book.cakephp.org">CakePHP Cookbook</a>.  It's a combination of manual and wiki, where people can flesh out the manual and make comments on the methods in there.  I have been quite harsh on people who have called for a CakePHP wiki in the past, because they tend to be a mess.  This project is just different enough that I cannot stop recommending people to use the cookbook when searching for answers to their CakePHP problems.  In fact, if you can contribute by moving entries over from the <a href="http://tempdocs.cakephp.org">temporary documentation</a> to the cookbook, _psychic_ will have one less thing to do.
</p>
<p>
From now on, whenever I find a solution to something in CakePHP I will not only post it here on my blog (because, after all, I am still an egomaniac) I will also create an entry in the Cookbook if it's appropriate.  Lucky for you, contributions are anonymous so you won't be able to tell what I've put in there.  My first contribution has been to get my documentation on the Auth component in there (although my simple user registration stuff isn't in there), and <a href="http://www.3hndesigns.com/">Baz</a> added his stuff he's been doing with Auth as well.
</p>
<p>
So, no more excuses about lack of documentation!  Anyone who registers and account can create entries in the manual, and everyone who complains about on the mailing list will be told to go look at the cookbook and contribute changes and comments to it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2008/02/18/cooking-up-some-cake/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>It&#8217;s Convention Season!</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/02/12/its-convention-season/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2008/02/12/its-convention-season/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 20:46:47 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Open Web Vancouver 2008]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/02/12/its-convention-season/</guid>
		<description><![CDATA[
Fresh off the middling success of my talk at CakeFest 2008, I'll be giving a more expanded version of the talk at Open Web Vancouver 2008, which is being held April 14 and 15, 2008 in Vancouver.  I really enjoyed going out there last year, and this talk is quite different from the last [...]]]></description>
			<content:encoded><![CDATA[<p>
Fresh off the middling success of my talk at <a href='http://cakefest.org'>CakeFest 2008</a>, I'll be giving a more expanded version of the talk at <a href='http://www.openwebvancouver.ca/'>Open Web Vancouver 2008</a>, which is being held April 14 and 15, 2008 in Vancouver.  I really enjoyed going out there last year, and this talk is quite different from the last one I gave.  However, I will have to flesh this one out as I will be talking to a crowd that might not necessarily be familiar with CakePHP, or even MVC frameworks as a whole.  The cute slides done by my kids are definitely going to stay in it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2008/02/12/its-convention-season/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Devil&#8217;s In The Details (or, Handling Sequences in Postgres in CakePHP)</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/02/02/the-devils-in-the-details-or-handling-sequences-in-postgres-in-cakephp/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2008/02/02/the-devils-in-the-details-or-handling-sequences-in-postgres-in-cakephp/#comments</comments>
		<pubDate>Sat, 02 Feb 2008 20:30:22 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Postgres]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/02/02/the-devils-in-the-details-or-handling-sequences-in-postgres-in-cakephp/</guid>
		<description><![CDATA[I had been struggling with some weirdness that CakePHP has been displaying while trying to add some new features to the baseball league website, where Cake + PHP 4.4 + Postgres were deciding to just be sulky and not work together well.

So, I was trying to figure out how to make a test for this [...]]]></description>
			<content:encoded><![CDATA[<p>I had been struggling with some weirdness that CakePHP has been displaying while trying to add some new features to the <a href="http://www.ibl.org">baseball league website</a>, where Cake + PHP 4.4 + Postgres were deciding to just be sulky and not work together well.</p>
<p>
So, I was trying to figure out how to make a test for this so I could file a bug (CakePHP not finding the proper name of the Postgres sequence for a table) when I tracked down <a href="http://cake.insertdesignhere.com/">nate</a> on IM to whine to him about this problem, he started bugging me about "not paying attention" when looking around in code to try and track down what I thought was a bug.  If I had looked at the API a little closer I would've been steered towards the solution he gave me.
</p>
<p>
Lucky for me, it turns out that the solution (for now) to the problem was to simply add the name of the sequence for that table as a variable to the model definition.</p>
<div class="igBar"><span id="lphp-6"><a href="#" onclick="javascript:showPlainTxt('php-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-6">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> Vote extends AppModel <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$name</span> = <span style="color:#FF0000;">'Vote'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$sequence</span> = <span style="color:#FF0000;">'votes_id_seq'</span>; <span style="color:#FF9933; font-style:italic;">// This is what I added in</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#FF9933; font-style:italic;">//The Associations below have been created with all possible keys, those that are not needed can be removed</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$belongsTo</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'BallotItem'</span> =&gt; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'className'</span> =&gt; <span style="color:#FF0000;">'BallotItem'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'foreignKey'</span> =&gt; <span style="color:#FF0000;">'ballot_item_id'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'conditions'</span> =&gt; <span style="color:#FF0000;">''</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'fields'</span> =&gt; <span style="color:#FF0000;">''</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'order'</span> =&gt; <span style="color:#FF0000;">''</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'Franchise'</span> =&gt; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'className'</span> =&gt; <span style="color:#FF0000;">'Franchise'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'foreignKey'</span> =&gt; <span style="color:#FF0000;">'franchise_id'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'conditions'</span> =&gt; <span style="color:#FF0000;">''</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'fields'</span> =&gt; <span style="color:#FF0000;">''</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'order'</span> =&gt; <span style="color:#FF0000;">''</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$validate</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'ballot_item_id'</span> =&gt; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'rule'</span> =&gt; <span style="color:#FF0000;">'numeric'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'required'</span> =&gt; <span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'franchise_id'</span> =&gt; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'rule'</span> =&gt; <span style="color:#FF0000;">'numeric'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'required'</span> =&gt; <span style="color:#000000; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'answer'</span> =&gt; <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'rule'</span> =&gt; <span style="color:#FF0000;">'numeric'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'required'</span> =&gt; <span style="color:#000000; font-weight:bold;">true</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#FF0000;">'message'</span> =&gt; <span style="color:#FF0000;">'You must vote on this item'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</p>
<p>
This confirmed to me that my new-found respect for trying to come up with the simplest solution to a problem is the correct way to do so.  Since my head is full of all sorts of nonsense (work items, family life, baseball stats, old Dungeons &#038; Dragons adventures from my teenage years) I find that at times I am better served by taking the time to think about the problem rather than start digging around.  Especially when it comes to code that was well-written an has been tested by lots of people, like the overwhelming majority of CakePHP's core code.
</p>
<p>
Thanks again to nate for proving to me that the Devil's in the details.  And continuing to make me feel stupid.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2008/02/02/the-devils-in-the-details-or-handling-sequences-in-postgres-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Going To CakeFest!</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/01/21/going-to-cakefest/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2008/01/21/going-to-cakefest/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 15:06:52 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[CakeFest]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2008/01/21/going-to-cakefest/</guid>
		<description><![CDATA[
Yes, it's been confirmed:  I will be attending CakeFest down in Orlando Feb. 6 to 8.  I'll be giving a talk entitled "Fake It Until You Make It" about how to use the Cake console tools to speed up your development.  I use the Cake console for all my CakePHP projects, since [...]]]></description>
			<content:encoded><![CDATA[<p>
Yes, it's been confirmed:  I will be attending <a href='http://www.cakefest.org'>CakeFest</a> down in Orlando Feb. 6 to 8.  I'll be giving a talk entitled "Fake It Until You Make It" about how to use the Cake console tools to speed up your development.  I use the Cake console for all my CakePHP projects, since it helps me quickly create the code for models, controllers (love being able to have all those admin methods already baked in) and I hope to show those who might be a little shy of using the command line what they are missing out on.
</p>
<p>
I'm going to be flying down Tuesday night, getting in around midnight and flying out Friday morning (it's looking like a 10:30 departure).  So that's two full days at the conference, which is okay.  Now, if anyone is going down there and could use a roomie to help cut down on costs let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2008/01/21/going-to-cakefest/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CakePHP Pagination With A HABTM Relationship</title>
		<link>http://www.littlehart.net/atthekeyboard/2007/12/11/cakephp-pagination-with-a-habtm-relationship/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss</link>
		<comments>http://www.littlehart.net/atthekeyboard/2007/12/11/cakephp-pagination-with-a-habtm-relationship/#comments</comments>
		<pubDate>Wed, 12 Dec 2007 03:27:26 +0000</pubDate>
		<dc:creator>Chris Hartjes</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[HABTM]]></category>
		<category><![CDATA[pagination]]></category>

		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/2007/12/11/cakephp-pagination-with-a-habtm-relationship/</guid>
		<description><![CDATA[There are usually lots of Has And Belongs To Many relationship questions on the CakePHP mailing list.  Since I am stupid about this stuff, I sought out Nate Abele and bugged him via IM until he agreed to give me an example of how to do this.  Thanks Nate!
PLAIN TEXT
PHP:




class Tag extends AppModel [...]]]></description>
			<content:encoded><![CDATA[<p>There are usually lots of Has And Belongs To Many relationship questions on the CakePHP mailing list.  Since I am stupid about this stuff, I sought out Nate Abele and bugged him via IM until he agreed to give me an example of how to do this.  Thanks Nate!</p>
<div class="igBar"><span id="lphp-8"><a href="#" onclick="javascript:showPlainTxt('php-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-8">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> Tag extends AppModel <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$hasAndBelongsToMany</span> = <span style="color:#FF0000;">'Post'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> paginate<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$conditions</span> = <span style="color:#000000; font-weight:bold;">null</span>, <span style="color:#0000FF;">$fields</span> = <span style="color:#000000; font-weight:bold;">null</span>, <span style="color:#0000FF;">$order</span> = <span style="color:#000000; font-weight:bold;">null</span>, <span style="color:#0000FF;">$limit</span> = <span style="color:#000000; font-weight:bold;">null</span>, <span style="color:#0000FF;">$page</span> = <span style="color:#CC66CC;color:#800000;">1</span>, <span style="color:#0000FF;">$recursive</span> = <span style="color:#000000; font-weight:bold;">null</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$tag</span> = <span style="color:#0000FF;">$conditions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'tag'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/unset"><span style="color:#000066;">unset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$conditions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'tag'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">hasAndBelongsToMany</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Post'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = am<span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">hasAndBelongsToMany</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Post'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/compact"><span style="color:#000066;">compact</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'conditions'</span>, <span style="color:#FF0000;">'fields'</span>, <span style="color:#FF0000;">'order'</span>, <span style="color:#FF0000;">'limit'</span>, <span style="color:#FF0000;">'page'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">findByName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$tag</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> paginateCount<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$conditions</span> = <span style="color:#000000; font-weight:bold;">null</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$tag</span> = <span style="color:#0000FF;">$conditions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'tag'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/unset"><span style="color:#000066;">unset</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$conditions</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'tag'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$tmp</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">hasAndBelongsToMany</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Post'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">hasAndBelongsToMany</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Post'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'fields'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'id'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$tag</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">findByName</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$tag</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">hasAndBelongsToMany</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Post'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$tmp</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <a href="http://www.php.net/count"><span style="color:#000066;">count</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$tag</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'Post'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Controller code</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$data</span> = <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">paginate</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'Tag'</span>, <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'tag'</span> =&gt; <span style="color:#0000FF;">$tag</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Where $tag = some tag name </span></div>
</li>
</ol>
</div>
</div>
</div>
<p>
Okay, that's great but WHY does it work?  Normally, when you do pagination you have to pass it a bunch of different parameters so it knows what records you wish to include as part of the data set you want to paginate over.  In this example, you've already established that Tag HABTM Post.  In order for the pagination query to correctly pull out the Posts that are also associated with the Tag, you need to merge the parameters you passed in to your 'paginate' method so that the CakePHP data mapping functionality knows what associated records are to be included.  Then run your $this->findByName(...) and you're all set.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.littlehart.net/atthekeyboard/2007/12/11/cakephp-pagination-with-a-habtm-relationship/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->