<?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>Coding My Thoughts &#187; CakePHP</title>
	<atom:link href="http://marianoiglesias.com.ar/category/cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://marianoiglesias.com.ar</link>
	<description>A glimpse at a coder&#039;s troubled mind</description>
	<lastBuildDate>Wed, 06 Jan 2010 19:25:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Pagination with custom find types in CakePHP</title>
		<link>http://marianoiglesias.com.ar/cakephp/pagination-with-custom-find-types-in-cakephp/</link>
		<comments>http://marianoiglesias.com.ar/cakephp/pagination-with-custom-find-types-in-cakephp/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 15:11:00 +0000</pubDate>
		<dc:creator>mariano</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://marianoiglesias.com.ar/1/pagination-with-custom-find-types-in-cakephp/</guid>
		<description><![CDATA[<p>With the release of <a href="http://cakephp.org" rel="nofollow" >CakePHP 1.2</a> a whole set of new features were made available to us bakers. One of those features is custom find types, which is one of the coolest things that ever happened since&#8230;</p>


Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/' rel='bookmark' title='Permanent Link: Modelizing HABTM join tables in CakePHP 1.2: with and auto-with models'>Modelizing HABTM join tables in CakePHP 1.2: with and auto-with models</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakephp-tip-of-the-day-pay-attention-to-conventions/' rel='bookmark' title='Permanent Link: CakePHP tip of the day: pay attention to conventions'>CakePHP tip of the day: pay attention to conventions</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/' rel='bookmark' title='Permanent Link: CakePHP 1.2 tip of the day: be mindful of Model::set'>CakePHP 1.2 tip of the day: be mindful of Model::set</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>With the release of <a href="http://cakephp.org" rel="nofollow" >CakePHP 1.2</a> a whole set of new features were made available to us bakers. One of those features is custom find types, which is one of the coolest things that ever happened since <a href="http://video.google.com/videoplay?docid=-5883772879840922003" rel="nofollow" >I realized I was cooler than Maverick</a>.</p>
<p>I&#8217;m not gonna go through custom find types, you can find more info about them <a href="http://www.pseudocoder.com/archives/2008/10/24/cakephp-custom-find-types/" rel="nofollow" >at Matt&#8217;s blog</a>, or at <a href="http://c7y.phparch.com/c/entry/1/art,mvc_and_cake" rel="nofollow" >this article</a> written by someone whose name I think I&#8217;ve heard somewhere. What I&#8217;m going to talk about is how to mix your custom find types with pagination, without having to use <a href="http://book.cakephp.org/view/249/Custom-Query-Pagination" rel="nofollow" >paginate and paginateCount</a> in your models.</p>
<p>So let&#8217;s first start by building yet another posts table, and inserting some records:</p>
<pre name="code" class="sql">CREATE TABLE `posts`(
	`id` INT NOT NULL AUTO_INCREMENT,
	`title` VARCHAR(255) NOT NULL,
	`body` TEXT NOT NULL,
	`published` TINYINT(1) NOT NULL default 0,
	`created` DATETIME,
	`modified` DATETIME,
	PRIMARY KEY(`id`)
);

INSERT INTO `posts`(`title`, `body`, `published`, `created`, `modified`) VALUES
	('Post 1', 'Body for Post 1', 1, NOW(), NOW()),
	('Post 2', 'Body for Post 2', 0, NOW(), NOW()),
	('Post 3', 'Body for Post 3', 0, NOW(), NOW()),
	('Post 4', 'Body for Post 4', 1, NOW(), NOW()),
	('Post 5', 'Body for Post 5', 1, NOW(), NOW()),
	('Post 6', 'Body for Post 6', 0, NOW(), NOW()),
	('Post 7', 'Body for Post 7', 1, NOW(), NOW()),
	('Post 8', 'Body for Post 8', 1, NOW(), NOW()),
	('Post 9', 'Body for Post 9', 1, NOW(), NOW());</pre>
<p>Now let&#8217;s assume we want a find type called <code>published</code> to fetch only the published posts, and that we also want to be able to paginate using this find type. We will be approaching this through a generic approach, something that can be used throughout all our models. With this in mind, let&#8217;s first introduce a model based member variable called <code>$_types</code>, where we define the specific needs of each custom find type. Therefore, that variable will hold what we need as conditions, order, etc. for each custom find type. So let&#8217;s build our <code>Post</code> model:</p>
<pre name="code" class="php">&lt;?php
class Post extends AppModel {
	public $name = 'Post';
	protected $_types = array(
		'published' =&gt; array(
			'conditions' =&gt; array('Post.published' =&gt; 1),
			'order' =&gt; array('Post.created' =&gt; 'desc')
		)
	);
}
?&gt;</pre>
<p>As you can see, we define options for each find type as if we would be calling <code>find()</code> directly. So with the above, instead of doing:</p>
<pre name="code" class="php">$posts = $this-&gt;Post-&gt;find('all', array(
	'conditions' =&gt; array('Post.published' =&gt; 1),
	'order' =&gt; array('Post.created' =&gt; 'desc')
));</pre>
<p>We can now do:</p>
<pre name="code" class="php">$posts = $this-&gt;Post-&gt;find('published');</pre>
<p>Now, what if we wanted to paginate with the above custom find type? Just as we set pagination parameters through the controller member variable <code>$paginate</code>, we can specify which find type pagination we&#8217;ll use. We do so by specifying the find type in the index 0 of the pagination settings. Like so:</p>
<pre name="code" class="php">$this-&gt;paginate['Post'] = array(
	'published',
	'limit' =&gt; 10
);

$posts = $this-&gt;paginate('Post');</pre>
<p>Easy, huh? When this is specified, paginate() does the following:</p>
<ol>
<li>It issues a <code>find('count')</code> on the Post model, specifying the custom find type (<code>published</code>) in the <code>$options</code> array, through an option named <code>type</code>. Therefore, we can use <code>$options['type']</code> when our model is about to do the count to use the given options for our custom find type.</li>
<li>It fetches the records by calling <code>find()</code> with the custom find type, <code>find('published')</code> in our example.</li>
</ol>
<p>So where&#8217;s that sexy code? Add the following in your <code>AppModel</code>, making the above available for all our models.</p>
<pre name="code" class="php">&lt;?php
class AppModel extends Model {
	public function find($type, $options = array()) {
		if (!empty($this-&gt;_types)) {
			$types = array_keys($this-&gt;_types);
			$type = (is_string($type) ? $type : null);
			if (!empty($type)) {
				if (($type == 'count' &amp;&amp; !empty($options['type']) &amp;&amp; in_array($options['type'], $types)) || in_array($type, $types)) {
					$options = Set::merge(
						$this-&gt;_types[($type == 'count' ? $options['type'] : $type)],
						array_diff_key($options, array('type'=&gt;true))
					);
				}
				if (in_array($type, $types)) {
					$type = (!empty($this-&gt;_types[$type]['type']) ? $this-&gt;_types[$type]['type'] : 'all');
				}
			}
		}
		return parent::find($type, $options);
	}
}
?&gt;</pre>
<p>Now ain&#8217;t CakePHP great? Don&#8217;t tell me, <a href="http://cakefest.org" rel="nofollow" >tell everyone at CakeFest #3</a>.</p>


<p>Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/' rel='bookmark' title='Permanent Link: Modelizing HABTM join tables in CakePHP 1.2: with and auto-with models'>Modelizing HABTM join tables in CakePHP 1.2: with and auto-with models</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakephp-tip-of-the-day-pay-attention-to-conventions/' rel='bookmark' title='Permanent Link: CakePHP tip of the day: pay attention to conventions'>CakePHP tip of the day: pay attention to conventions</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/' rel='bookmark' title='Permanent Link: CakePHP 1.2 tip of the day: be mindful of Model::set'>CakePHP 1.2 tip of the day: be mindful of Model::set</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://marianoiglesias.com.ar/cakephp/pagination-with-custom-find-types-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>CakeFest #3: CakePHP in Berlin, July 9-12</title>
		<link>http://marianoiglesias.com.ar/cakephp/cakefest-3-cakephp-in-berlin-july-9-12/</link>
		<comments>http://marianoiglesias.com.ar/cakephp/cakefest-3-cakephp-in-berlin-july-9-12/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 16:53:00 +0000</pubDate>
		<dc:creator>mariano</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://marianoiglesias.com.ar/1/cakefest-3-cakephp-in-berlin-july-9-12/</guid>
		<description><![CDATA[<div>
<p>What better place to talk CakePHP than the world&#8217;s beer nation? That was the question that made the CakePHP Team decide CakeFest third edition should be located in Berlin, Germany. Just as Buenos Aires was the meat fest, I</p></div><p>&#8230;</p>


Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/cakephp-1-2-beta-released-and-cakefest-site-launched/' rel='bookmark' title='Permanent Link: CakePHP 1.2 beta released and CakeFest site launched'>CakePHP 1.2 beta released and CakeFest site launched</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/my-talk-in-cakefest-behaviors/' rel='bookmark' title='Permanent Link: My talk in CakeFest: behaviors'>My talk in CakeFest: behaviors</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-was-a-success/' rel='bookmark' title='Permanent Link: CakeFest was a success'>CakeFest was a success</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div>
<p>What better place to talk CakePHP than the world&#8217;s beer nation? That was the question that made the CakePHP Team decide CakeFest third edition should be located in Berlin, Germany. Just as Buenos Aires was the meat fest, I hereby predict that this will be the Beer Fest.</p>
<p>Let&#8217;s face it, your code gets better when you use CakePHP. So attending the official CakePHP gathering where all Core Developers and prominent community members go to share their knowledge is an offer you should not ignore. Add awesome beer and guaranteed fun to that recipe, and you would be insane not to join us.</p>
<p>So what are you waiting for? Go and <a href="http://cakefest.org/registrations/add" rel="nofollow" >get your CakeFest ticket</a> as soon as possible, you don&#8217;t want to be left behind! If you have a company, or you are a regular Baker just wanting to show your love back to the project, do not hesitate to <a href="http://cakefest.org/pages/sponsors" rel="nofollow" >sign up for the sponsorship packages</a>. Also help us spread the word by <a href="http://cakefest.org/pages/badges" rel="nofollow" >placing these CakeFest badges</a> in your site, and you may even get a free ticket!</p>
</div>


<p>Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/cakephp-1-2-beta-released-and-cakefest-site-launched/' rel='bookmark' title='Permanent Link: CakePHP 1.2 beta released and CakeFest site launched'>CakePHP 1.2 beta released and CakeFest site launched</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/my-talk-in-cakefest-behaviors/' rel='bookmark' title='Permanent Link: My talk in CakeFest: behaviors'>My talk in CakeFest: behaviors</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-was-a-success/' rel='bookmark' title='Permanent Link: CakeFest was a success'>CakeFest was a success</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://marianoiglesias.com.ar/cakephp/cakefest-3-cakephp-in-berlin-july-9-12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVN rename all your CakePHP views from thtml to ctp</title>
		<link>http://marianoiglesias.com.ar/cakephp/svn-rename-all-your-cakephp-views-from-thtml-to-ctp/</link>
		<comments>http://marianoiglesias.com.ar/cakephp/svn-rename-all-your-cakephp-views-from-thtml-to-ctp/#comments</comments>
		<pubDate>Wed, 28 May 2008 16:53:00 +0000</pubDate>
		<dc:creator>mariano</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://marianoiglesias.com.ar/1/svn-rename-all-your-cakephp-views-from-thtml-to-ctp/</guid>
		<description><![CDATA[<p>As I recently moved to Ubuntu 8.04 (plus CompizFusion + AWN which is rocking my world), I am now back to the good old days where bash was there to save my life. So basically I needed to SVN rename&#8230;</p>


Related posts:<ol><li><a href='http://marianoiglesias.com.ar/ubuntu/simple-backup-script-for-ubuntu/' rel='bookmark' title='Permanent Link: Simple backup script for Ubuntu'>Simple backup script for Ubuntu</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/using-configure-in-cakephp-applications/' rel='bookmark' title='Permanent Link: Using Configure in CakePHP applications'>Using Configure in CakePHP applications</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>As I recently moved to Ubuntu 8.04 (plus CompizFusion + AWN which is rocking my world), I am now back to the good old days where bash was there to save my life. So basically I needed to SVN rename (also known as move) all my thtml views to ctp, recursively. Since this is a short tip, I&#8217;ll get down to the details. Just cd to your /views path in CakePHP, and issue:</p>
<pre name="code">for file in `find . -name "*.thtml"` ; do svn mv $file `echo $file | sed s/\.thtml/\.ctp/` ; done</pre>
<p>After that you can safely commit. Enjoy!</p>


<p>Related posts:<ol><li><a href='http://marianoiglesias.com.ar/ubuntu/simple-backup-script-for-ubuntu/' rel='bookmark' title='Permanent Link: Simple backup script for Ubuntu'>Simple backup script for Ubuntu</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/using-configure-in-cakephp-applications/' rel='bookmark' title='Permanent Link: Using Configure in CakePHP applications'>Using Configure in CakePHP applications</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://marianoiglesias.com.ar/cakephp/svn-rename-all-your-cakephp-views-from-thtml-to-ctp/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>CakeFest was a success</title>
		<link>http://marianoiglesias.com.ar/cakephp/cakefest-was-a-success/</link>
		<comments>http://marianoiglesias.com.ar/cakephp/cakefest-was-a-success/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 18:19:00 +0000</pubDate>
		<dc:creator>mariano</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://marianoiglesias.com.ar/1/cakefest-was-a-success/</guid>
		<description><![CDATA[<div>
<p>I came back to Buenos Aires the day before yesterday, after a wonderful experience in Orlando. <a href="http://www.cakefest.org" rel="nofollow" >CakeFest</a> was not only a great opportunity to be a part of the first official CakePHP gathering, but most importantly</p></div><p>&#8230;</p>


Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-3-cakephp-in-berlin-july-9-12/' rel='bookmark' title='Permanent Link: CakeFest #3: CakePHP in Berlin, July 9-12'>CakeFest #3: CakePHP in Berlin, July 9-12</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakephp-1-2-beta-released-and-cakefest-site-launched/' rel='bookmark' title='Permanent Link: CakePHP 1.2 beta released and CakeFest site launched'>CakePHP 1.2 beta released and CakeFest site launched</a></li>
<li><a href='http://marianoiglesias.com.ar/business/cakefest-2-coming-up/' rel='bookmark' title='Permanent Link: CakeFest #2 coming up'>CakeFest #2 coming up</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div>
<p>I came back to Buenos Aires the day before yesterday, after a wonderful experience in Orlando. <a href="http://www.cakefest.org" rel="nofollow" >CakeFest</a> was not only a great opportunity to be a part of the first official CakePHP gathering, but most importantly to meet a lot of smart people. As I said to someone while in Orlando, eventhough all the talks were thorough and hands-down interesting, I found that the after hours were the moments where I got most out of the conference. Just hanging out with fellow bakers, drinking beer (lots of beer) and talking code to each other was an incredible opportunity.</p>
<p>I enjoyed my time there so much that I came back completely decided to host a CakeFest in Buenos Aires, Argentina during the first week of December, 2008. I am already taking care of the organization and will open up inscriptions very soon (so now you can&#8217;t complain, you have almost 10 months of notice.) Some of the talks will be english and some in spanish, so everyone is invited to join. As a corolary, I&#8217;ll leave you with some pictures taken in Orlando (wish I would&#8217;ve taken more). Click on the pictures to get their respective bigger size photos.</p>
<p><strong>DOWNLOAD</strong>: In case you are interested, you can download the slides of my presentation entitled <a href="http://cricava.com/blogs/media/el_eternauta/posts/behaviors_making_your_models_behave.pdf" rel="nofollow" >Behaviors: Making your Models Behave</a>.</p>
<table border="0" align="center">
<tr>
<td><a href="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-lunch.jpg" rel="nofollow"  target="_blank"><img src="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-lunch-thumb.jpg" border="0" alt="" width="200" height="150" /></a><br />Lunch</td>
<td><a href="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-lunch_2.jpg" rel="nofollow"  target="_blank"><img src="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-lunch_2-thumb.jpg" border="0" alt="" width="200" height="150" /></a><br />Chit chat at salad bar</td>
</tr>
<tr>
<td><a href="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-gwoo_mac.jpg" rel="nofollow"  target="_blank"><img src="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-gwoo_mac-thumb.jpg" border="0" alt="" width="200" height="150" /></a><br />Gwoo and his Mac</td>
<td><a href="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-gwoo_keynote.jpg" rel="nofollow"  target="_blank"><img src="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-gwoo_keynote-thumb.jpg" border="0" alt="" width="200" height="150" /></a><br />Gwoo&#8217;s keynote</td>
</tr>
<tr>
<td><a href="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-felix_tim_and_me.jpg" rel="nofollow"  target="_blank"><img src="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-felix_tim_and_me-thumb.jpg" border="0" alt="" width="200" height="116" /></a><br />Felix (the_undefined), Tim and me</td>
<td><a href="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-phishy_and_me.jpg" rel="nofollow"  target="_blank"><img src="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-phishy_and_me-thumb.jpg" border="0" alt="" width="200" height="114" /></a><br />Jeff (phishy) and me. Marc in the background.</td>
</tr>
<tr>
<td><a href="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-dennis_and_me.jpg" rel="nofollow"  target="_blank"><img src="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-dennis_and_me-thumb.jpg" border="0" alt="" width="200" height="146" /></a><br />Dennis and me</td>
<td><a href="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-team.jpg" rel="nofollow"  target="_blank"><img src="http://cricava.com/blogs/media/el_eternauta/posts/cakefest-team-thumb.jpg" border="0" alt="" width="200" height="124" /></a><br />Some of CakeFest team</td>
</tr>
</table>
</div>


<p>Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-3-cakephp-in-berlin-july-9-12/' rel='bookmark' title='Permanent Link: CakeFest #3: CakePHP in Berlin, July 9-12'>CakeFest #3: CakePHP in Berlin, July 9-12</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakephp-1-2-beta-released-and-cakefest-site-launched/' rel='bookmark' title='Permanent Link: CakePHP 1.2 beta released and CakeFest site launched'>CakePHP 1.2 beta released and CakeFest site launched</a></li>
<li><a href='http://marianoiglesias.com.ar/business/cakefest-2-coming-up/' rel='bookmark' title='Permanent Link: CakeFest #2 coming up'>CakeFest #2 coming up</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://marianoiglesias.com.ar/cakephp/cakefest-was-a-success/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>CakeFest starting tomorrow</title>
		<link>http://marianoiglesias.com.ar/cakephp/cakefest-starting-tomorrow/</link>
		<comments>http://marianoiglesias.com.ar/cakephp/cakefest-starting-tomorrow/#comments</comments>
		<pubDate>Tue, 05 Feb 2008 18:05:00 +0000</pubDate>
		<dc:creator>mariano</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://marianoiglesias.com.ar/1/cakefest-starting-tomorrow/</guid>
		<description><![CDATA[<div>
<p>With just hours left to launch the first <a href="http://www.cakefest.org" rel="nofollow" >CakeFest</a> conference, people are starting to show up and speakers are working &#8217;round the clock with their presentations. However, something has been catching my attention since I came</p></div><p>&#8230;</p>


Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-was-a-success/' rel='bookmark' title='Permanent Link: CakeFest was a success'>CakeFest was a success</a></li>
<li><a href='http://marianoiglesias.com.ar/general/seven-things-you-dont-know-about-me-meme/' rel='bookmark' title='Permanent Link: Seven Things You Don&#8217;t Know About Me (MEME)'>Seven Things You Don&#8217;t Know About Me (MEME)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div>
<p>With just hours left to launch the first <a href="http://www.cakefest.org" rel="nofollow" >CakeFest</a> conference, people are starting to show up and speakers are working &#8217;round the clock with their presentations. However, something has been catching my attention since I came to the hotel: I am different. That&#8217;s right, I am unique. I stand out as an oasis in the middle of the desert. Don&#8217;t take my word for it, just look at my dear old Thinkpad standing in a pool of Macs. And in case you are wondering, people there from left to right are: Jeff Loiselle (aka phishy), Felix Geisend&#246;rfer (aka the_undefined), Tim Koschuetzki, and giving his back is Dennis Hennen.</p>
<p align="center"><img src="http://cricava.com/blogs/media/el_eternauta/posts/mac-ownage.jpg" border="0" alt="" width="512" height="384" /></p>
</div>


<p>Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-was-a-success/' rel='bookmark' title='Permanent Link: CakeFest was a success'>CakeFest was a success</a></li>
<li><a href='http://marianoiglesias.com.ar/general/seven-things-you-dont-know-about-me-meme/' rel='bookmark' title='Permanent Link: Seven Things You Don&#8217;t Know About Me (MEME)'>Seven Things You Don&#8217;t Know About Me (MEME)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://marianoiglesias.com.ar/cakephp/cakefest-starting-tomorrow/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My talk in CakeFest: behaviors</title>
		<link>http://marianoiglesias.com.ar/cakephp/my-talk-in-cakefest-behaviors/</link>
		<comments>http://marianoiglesias.com.ar/cakephp/my-talk-in-cakefest-behaviors/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 17:51:00 +0000</pubDate>
		<dc:creator>mariano</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://marianoiglesias.com.ar/1/my-talk-in-cakefest-behaviors/</guid>
		<description><![CDATA[<div>
<p>With the recent release of the <a href="http://www.cakefest.org/pages/schedule" rel="nofollow" >confirmed schedule</a> for the <a href="http://www.cakefest.org" rel="nofollow" >CakeFest conference</a>, you can see that my talk entitled <strong>Making your Models Behave</strong> has been allocated for Friday, February 8 at 11.15 am.</p></div><p>&#8230;</p>


Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-3-cakephp-in-berlin-july-9-12/' rel='bookmark' title='Permanent Link: CakeFest #3: CakePHP in Berlin, July 9-12'>CakeFest #3: CakePHP in Berlin, July 9-12</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-was-a-success/' rel='bookmark' title='Permanent Link: CakeFest was a success'>CakeFest was a success</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakephp-1-2-beta-released-and-cakefest-site-launched/' rel='bookmark' title='Permanent Link: CakePHP 1.2 beta released and CakeFest site launched'>CakePHP 1.2 beta released and CakeFest site launched</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div>
<p>With the recent release of the <a href="http://www.cakefest.org/pages/schedule" rel="nofollow" >confirmed schedule</a> for the <a href="http://www.cakefest.org" rel="nofollow" >CakeFest conference</a>, you can see that my talk entitled <strong>Making your Models Behave</strong> has been allocated for Friday, February 8 at 11.15 am. Right after Nate&#8217;s keynote, and before lunch, what an honor <img src='http://marianoiglesias.com.ar/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>For those of you who are attending my talk will be focused in understanding and exploiting the potential of what I consider to be one of the coolest features CakePHP has brought us: model behaviors. And for those of you who are not going, what are you waiting for? There are still tickets available. Reserve your flight and your stay, and head on to the conference.</p>
<p>If for some reason or another you are not going, we will be releasing the presentation slides on the CakeFest site sometime in the feature.</p>
</div>


<p>Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-3-cakephp-in-berlin-july-9-12/' rel='bookmark' title='Permanent Link: CakeFest #3: CakePHP in Berlin, July 9-12'>CakeFest #3: CakePHP in Berlin, July 9-12</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-was-a-success/' rel='bookmark' title='Permanent Link: CakeFest was a success'>CakeFest was a success</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakephp-1-2-beta-released-and-cakefest-site-launched/' rel='bookmark' title='Permanent Link: CakePHP 1.2 beta released and CakeFest site launched'>CakePHP 1.2 beta released and CakeFest site launched</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://marianoiglesias.com.ar/cakephp/my-talk-in-cakefest-behaviors/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CakePHP 1.2 beta released and CakeFest site launched</title>
		<link>http://marianoiglesias.com.ar/cakephp/cakephp-1-2-beta-released-and-cakefest-site-launched/</link>
		<comments>http://marianoiglesias.com.ar/cakephp/cakephp-1-2-beta-released-and-cakefest-site-launched/#comments</comments>
		<pubDate>Wed, 02 Jan 2008 20:44:00 +0000</pubDate>
		<dc:creator>mariano</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://marianoiglesias.com.ar/1/cakephp-1-2-beta-released-and-cakefest-site-launched/</guid>
		<description><![CDATA[<div>
<p>
A lot has happened in the last few weeks, but it all came together today: <a href="http://bakery.cakephp.org/articles/view/new-year-new-beta" rel="nofollow" >CakePHP 1.2</a> has reached its beta status and the <a href="http://www.cakefest.org" rel="nofollow" >CakeFest website</a> has launched officialy. CakeFest is the</p></div><p>&#8230;</p>


Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-3-cakephp-in-berlin-july-9-12/' rel='bookmark' title='Permanent Link: CakeFest #3: CakePHP in Berlin, July 9-12'>CakeFest #3: CakePHP in Berlin, July 9-12</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-was-a-success/' rel='bookmark' title='Permanent Link: CakeFest was a success'>CakeFest was a success</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/response-to-dho-leaving-the-cakephp-team/' rel='bookmark' title='Permanent Link: Response to dho leaving the CakePHP team'>Response to dho leaving the CakePHP team</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div>
<p>
A lot has happened in the last few weeks, but it all came together today: <a href="http://bakery.cakephp.org/articles/view/new-year-new-beta" rel="nofollow" >CakePHP 1.2</a> has reached its beta status and the <a href="http://www.cakefest.org" rel="nofollow" >CakeFest website</a> has launched officialy. CakeFest is the first official gathering related to CakePHP, and will be celebrated in Orlando, Florida, on February 6, 7, and 8, 2008. You&#8217;ll get a chance to see  experienced CakePHP developers (that&#8217;s right, the core team will be there) sharing their knowledge in talks and different events. I will be there as well, regardless if that&#8217;s good or bad news to you all. So don&#8217;t wait any longer, go and find out about the <a href="http://www.cakefest.org" rel="nofollow" >CakePHP festivities</a> and save your ticket <img src='http://marianoiglesias.com.ar/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />
</p>
</div>


<p>Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-3-cakephp-in-berlin-july-9-12/' rel='bookmark' title='Permanent Link: CakeFest #3: CakePHP in Berlin, July 9-12'>CakeFest #3: CakePHP in Berlin, July 9-12</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/cakefest-was-a-success/' rel='bookmark' title='Permanent Link: CakeFest was a success'>CakeFest was a success</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/response-to-dho-leaving-the-cakephp-team/' rel='bookmark' title='Permanent Link: Response to dho leaving the CakePHP team'>Response to dho leaving the CakePHP team</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://marianoiglesias.com.ar/cakephp/cakephp-1-2-beta-released-and-cakefest-site-launched/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ExpectsBehavior, model unbinding in CakePHP 1.2</title>
		<link>http://marianoiglesias.com.ar/cakephp/expectsbehavior-model-unbinding-in-cakephp-1-2/</link>
		<comments>http://marianoiglesias.com.ar/cakephp/expectsbehavior-model-unbinding-in-cakephp-1-2/#comments</comments>
		<pubDate>Mon, 29 Oct 2007 23:21:00 +0000</pubDate>
		<dc:creator>mariano</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://marianoiglesias.com.ar/1/expectsbehavior-model-unbinding-in-cakephp-1-2/</guid>
		<description><![CDATA[<p>
<strong>UPDATE</strong>: the first beta version has been released, and renamed to Bindable Behavior. Check it out at its bakery tutorial <a href="http://bakery.cakephp.org/articles/view/bindable-behavior-control-your-model-bindings" rel="nofollow" >Bindable Behavior: control your model bindings</a>.
</p>
<p>
It&#8217;s been some time since I&#8217;ve done any&#8230;</p>


Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/limiting-the-associated-models-returned-with-cakephp/' rel='bookmark' title='Permanent Link: Limiting the associated models returned with CakePHP'>Limiting the associated models returned with CakePHP</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/' rel='bookmark' title='Permanent Link: Modelizing HABTM join tables in CakePHP 1.2: with and auto-with models'>Modelizing HABTM join tables in CakePHP 1.2: with and auto-with models</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/using-configure-in-cakephp-applications/' rel='bookmark' title='Permanent Link: Using Configure in CakePHP applications'>Using Configure in CakePHP applications</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>
<strong>UPDATE</strong>: the first beta version has been released, and renamed to Bindable Behavior. Check it out at its bakery tutorial <a href="http://bakery.cakephp.org/articles/view/bindable-behavior-control-your-model-bindings" rel="nofollow" >Bindable Behavior: control your model bindings</a>.
</p>
<p>
It&#8217;s been some time since I&#8217;ve done any work on <a href="http://bakery.cakephp.org/articles/view/an-improvement-to-unbindmodel-on-model-side" rel="nofollow" >expects</a>, and while enjoying the incredible set of cool features CakePHP 1.2 pre-beta is giving us all, I decided it was time to let expects meet 1.2. My new baby is called <strong>ExpectsBehavior</strong>. As its 1.1 predecessor, its main goal is to provide a wrapper for CakePHP&#8217;s unbindModel function, to let the developer specify what bindings (model relationships) he&#8217;s expecting right before a find. At the same time, I needed some new features to be added, some of them courtesy of the previous brain work Felix did on his very cool <a href="http://www.thinkingphp.org/2007/06/14/containable-20-beta/" rel="nofollow" >Containable behavior</a>.
</p>
<p><span id="more-27"></span></p>
<p>
So what are some of these cool new features I&#8217;m talking about?
</p>
<ul>
<li><strong>Parameter notation flexibility</strong>: you can choose different ways on how to specify the models you need. Whatever is sexier for you!</li>
<li><strong>Calling methods</strong>: you can use the old way (calling Article-&gt;expects() right before your find), or use the newly CakePHP find notation with embedded parameters for the behavior, specifying your expects setting right on the Model::find() call.</li>
<li><strong>Override binding settings</strong>: tired of having to do a bindModel() to override some binding settings (such as limit, order, offset) right before your expects call? Want to only get certain fields of a related model, instead of all of them? Don&#8217;t stress! ExpectsBehavior allows you to override these settings easily.</li>
<li><strong>Auto recursivity</strong>: by default, ExpectsBehavior will determine the necessary recursivity needed to fetch the models you specified, and will set the main model recursivity accordingly. This feature can be disabled via a behavior setting.</li>
<li><strong>Warnings</strong>: if you enable a behavior setting, ExpectsBehavior will issue notices when specified bindings do not really exist. By default this setting is disabled.</li>
<li><strong>Thorough testing</strong>: I&#8217;m working very hard in adding tests for almost every conceivable aspect of the ExpectsBehavior. I&#8217;m already at 433 asserts, and counting! All succeeding, naturally <img src='http://marianoiglesias.com.ar/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
</ul>
<p>
Let&#8217;s start with the basics: <strong>parameter notation</strong>. ExpectsBehavior allows you to use two types of alternative notations when defining the bindings you are expecting: dot notation, and depth notation. Dot notation comes from expects 1.1, while depth notation is an alternative way where you specify the models using associative arrays. Let&#8217;s start with some samples (both calls will produce the same result):
</p>
<pre name="code" class="php">// Dot notation

$this-&gt;Article-&gt;expects('Category', 'Comment.User', 'Tag');

// Depth notation

$this-&gt;Article-&gt;expects(array('Category', 'Comment' =&gt; 'User', 'Tag'));</pre>
<p>
Ok, let&#8217;s get a little deeper:
</p>
<pre name="code" class="php">// Dot notation

$this-&gt;Article-&gt;expects('Category.Section', 'Comment.User.Profile', 'Tag');

// Depth notation

$this-&gt;Article-&gt;expects(array('Category' =&gt; 'Section', 'Comment' =&gt; array('User' =&gt; 'Profile'), 'Tag'));</pre>
<p>
What about mixing them up?
</p>
<pre name="code" class="php">$this-&gt;Article-&gt;expects(array('Category' =&gt; 'Section', 'Comment' =&gt; 'User.Profile', 'Tag'));</pre>
<p>
Cool, huh? Now, with <strong>calling methods</strong> you can still call expects the way we&#8217;ve just seen (the old way), or use the new, cool way: embedded parameters. Instead of doing:
</p>
<pre name="code" class="php">$this-&gt;Article-&gt;expects(array('Category', 'Comment' =&gt; 'User', 'Tag'));
$result = $this-&gt;Article-&gt;findAll();</pre>
<p>
Why not just do:
</p>
<pre name="code" class="php">$result = $this-&gt;Article-&gt;find('all', array('expects' =&gt; array(
	'Category', 'Comment' =&gt; 'User', 'Tag'
)));</pre>
<p>
Wait, does that really work? Yeah it does! Really? Of course! But don&#8217;t go anywhere, there&#8217;s more. Amongst the features I mentioned you can now <strong>override binding settings</strong>. Let&#8217;s see some code! Assume we just want the fields &#8216;username&#8217;, and &#8216;email&#8217; for the User binding on our previous call, so we simply change it to:
</p>
<pre name="code" class="php">$result = $this-&gt;Article-&gt;find('all', array('expects' =&gt; array(
	'Category',
	'Comment' =&gt; array('User' =&gt; array('username', 'email')),
	'Tag'
)));</pre>
<p>
Or if you don&#8217;t like seeing so many arrays, use the embedded field notation:
</p>
<pre name="code" class="php">$result = $this-&gt;Article-&gt;find('all', array('expects' =&gt; array(
	'Category',
	'Comment' =&gt; 'User(username, email)',
	'Tag'
)));</pre>
<p>
What about mixing fields and inner models? Let&#8217;s bring up the Profile attached to a User, and the Friend the user&#8217;s got:
</p>
<pre name="code" class="php">$result = $this-&gt;Article-&gt;find('all', array('expects' =&gt; array(
	'Category',
	'Comment' =&gt; array('User' =&gt; array('username', 'email', 'Profile', 'Friend')),
	'Tag'
)));</pre>
<p>
What about other settings? Like limit, and order? Sure, no problem. Say we want to get only the first 5 tags related to the articles, and order them by their field tag. Then let&#8217;s change the above to:
</p>
<pre name="code" class="php">$result = $this-&gt;Article-&gt;find('all', array('expects' =&gt; array(
	'Category',
	'Comment' =&gt; array('User' =&gt; array('username', 'email', 'Profile', 'Friend')),
	'Tag' =&gt; array('limit' =&gt; 5, 'order' =&gt; 'tag ASC')
)));</pre>
<p>
I&#8217;m not yet releasing it since I want to add further testing, but I will be posting the sourcecode on a live server very soon. So stay tuned, and until then I welcome your feedback.</p>


<p>Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/limiting-the-associated-models-returned-with-cakephp/' rel='bookmark' title='Permanent Link: Limiting the associated models returned with CakePHP'>Limiting the associated models returned with CakePHP</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/modelizing-habtm-join-tables-in-cakephp-1-2-with-and-auto-with-models/' rel='bookmark' title='Permanent Link: Modelizing HABTM join tables in CakePHP 1.2: with and auto-with models'>Modelizing HABTM join tables in CakePHP 1.2: with and auto-with models</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/using-configure-in-cakephp-applications/' rel='bookmark' title='Permanent Link: Using Configure in CakePHP applications'>Using Configure in CakePHP applications</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://marianoiglesias.com.ar/cakephp/expectsbehavior-model-unbinding-in-cakephp-1-2/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>CakePHP tip of the day: pay attention to conventions</title>
		<link>http://marianoiglesias.com.ar/cakephp/cakephp-tip-of-the-day-pay-attention-to-conventions/</link>
		<comments>http://marianoiglesias.com.ar/cakephp/cakephp-tip-of-the-day-pay-attention-to-conventions/#comments</comments>
		<pubDate>Tue, 23 Oct 2007 20:31:00 +0000</pubDate>
		<dc:creator>mariano</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://marianoiglesias.com.ar/1/cakephp-tip-of-the-day-pay-attention-to-conventions/</guid>
		<description><![CDATA[<p>
CakePHP 1.2 sexyness is mainly a result of its convention over configuration methodology. Theoretical discussions aside, conventions save us (developers) valuable time, and allow us to concentrate on where we should put our effort: business logic. Some conventions may&#8230;</p>


Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/' rel='bookmark' title='Permanent Link: CakePHP 1.2 tip of the day: be mindful of Model::set'>CakePHP 1.2 tip of the day: be mindful of Model::set</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/something-to-consider-when-saving-habtm-records-in-cakephp/' rel='bookmark' title='Permanent Link: Something to consider when saving HABTM records in CakePHP'>Something to consider when saving HABTM records in CakePHP</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/pagination-with-custom-find-types-in-cakephp/' rel='bookmark' title='Permanent Link: Pagination with custom find types in CakePHP'>Pagination with custom find types in CakePHP</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>
CakePHP 1.2 sexyness is mainly a result of its convention over configuration methodology. Theoretical discussions aside, conventions save us (developers) valuable time, and allow us to concentrate on where we should put our effort: business logic. Some conventions may go under the radar until you find what <strong>you think</strong> is a weird bug. Let&#8217;s see an example by building a simple action in a controller:
</p>
<p><span id="more-28"></span></p>
<pre name="code" class="php">class PostsController extends AppController {
	function edit($slug) {
		$post = $this-&gt;Post-&gt;findBySlug($slug);

		if (!empty($this-&gt;data)) {
			// We have the post already, so don't let user submit and ID
			// in POSTed information, just in case he gets funky ideas

			if (isset($this-&gt;data['Post']['id'])) {
				unset($this-&gt;data['Post']['id']);
			}

			$this-&gt;Post-&gt;set($this-&gt;data);
			if ($this-&gt;Post-&gt;validates()) {
				// Force correct ID
				$this-&gt;data['Post']['id'] = $post['Post']['id'];

				// Do something else we need to do before saving
				// ...

				// and now save
				$this-&gt;Post-&gt;save($this-&gt;data);
			}
		}
	}
}</pre>
<p>
To our surprise, you&#8217;ll see that the above code always generates a new Post, instead of editing the post which slug is $slug. Why is that? I&#8217;ll give you a hint: print out $this->Post->id just before you execute the validates(), and you&#8217;ll see that it is set to whatever the slug is. What? So ID is set to a slug? Now, why the heck is that? Let&#8217;s dive into CakePHP core code, and pay special attention to the first few lines of Controller::constructClasses():
</p>
<pre name="code" class="php">if (empty($this-&gt;passedArgs) || !isset($this-&gt;passedArgs['0'])) {
	$id = false;
} else {
	$id = $this-&gt;passedArgs['0'];
}

if ($this-&gt;uses === false) {
	$this-&gt;loadModel($this-&gt;modelClass, $id);
} elseif ($this-&gt;uses) {
	$uses = is_array($this-&gt;uses) ? $this-&gt;uses : array($this-&gt;uses);
	$this-&gt;modelClass = $uses[0];
	foreach ($uses as $modelClass) {
		$this-&gt;loadModel($modelClass);
	}
}</pre>
<p>
As you can see CakePHP, when only the auto-model linked to our controller is used (i.e: we&#8217;re not using Controller::$uses), will assume that the first parameter sent to the current action (if there&#8217;s indeed one) corresponds to the model ID. Therefore on our case it is set to whatever the $slug passed was. Now you may be asking, why should that still be a problem if we&#8217;re forcing the ID right before the save? Once again, let&#8217;s dive into the core, and see that when Model::invalidFields() (called by Model::validates()) is figuring out what rules to execute during validation, it does the following so it knows if the current record being validated is a new record, or an existing one:
</p>
<pre name="code" class="php">$exists = $this-&gt;exists();</pre>
<p>
For performance reasons, Model::exists() will save internally a variable so the next time someone calls Model::exists() it doesn&#8217;t have to execute another COUNT, unless you force it (by passing true as a parameter to exists). Model::save() naturally needs to know if the record exists to figure out if it&#8217;s an INSERT or an UPDATE. How does it find out? You&#8217;ve guessed it: by calling exists:
</p>
<pre name="code" class="php">$exists = $this-&gt;exists();</pre>
<p>
It is not forcing exists() to re-run the query, which means on our case Model::exists() will return the value found the last time it was executed, which was back when the model was being validated. At that time Model::$id was set to $slug, so naturally Model::exists() said this record doesn&#8217;t exist. Hence, Model::save() thinks now the record doesn&#8217;t exist, and the save gets executed as an INSERT.
</p>
<p>
Now don&#8217;t get all hasty and think this is a bug, or complain saying that Model::save() should force Model::exists() to refresh. Instead think that we may be missing the point: there&#8217;s another convention which says Model should know the real Model ID before a validation is performed. It is a convention for our own benefit: so we can specify certain validation rules to run only on update, create, or both. So we need to change our code and <strong>make sure that the right model ID</strong> is set before executing Model::validates():
</p>
<pre name="code" class="php">class PostsController extends AppController {
	function edit($slug) {
		$post = $this-&gt;Post-&gt;findBySlug($slug);

		if (!empty($this-&gt;data)) {
			// Let's force the ID, just in case user gets funky ideas
			$this-&gt;data['Post']['id'] = $post['Post']['id'];

			$this-&gt;Post-&gt;set($this-&gt;data);
			if ($this-&gt;Post-&gt;validates()) {
				// Do something else we need to do before saving
				// ...

				// and now save
				$this-&gt;Post-&gt;save($this-&gt;data);
			}
		}
	}
}</pre>


<p>Related posts:<ol><li><a href='http://marianoiglesias.com.ar/cakephp/cakephp-1-2-tip-of-the-day-be-mindful-of-modelset/' rel='bookmark' title='Permanent Link: CakePHP 1.2 tip of the day: be mindful of Model::set'>CakePHP 1.2 tip of the day: be mindful of Model::set</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/something-to-consider-when-saving-habtm-records-in-cakephp/' rel='bookmark' title='Permanent Link: Something to consider when saving HABTM records in CakePHP'>Something to consider when saving HABTM records in CakePHP</a></li>
<li><a href='http://marianoiglesias.com.ar/cakephp/pagination-with-custom-find-types-in-cakephp/' rel='bookmark' title='Permanent Link: Pagination with custom find types in CakePHP'>Pagination with custom find types in CakePHP</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://marianoiglesias.com.ar/cakephp/cakephp-tip-of-the-day-pay-attention-to-conventions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Comparing CakePHP with other frameworks</title>
		<link>http://marianoiglesias.com.ar/cakephp/comparing-cakephp-with-other-frameworks/</link>
		<comments>http://marianoiglesias.com.ar/cakephp/comparing-cakephp-with-other-frameworks/#comments</comments>
		<pubDate>Fri, 12 Oct 2007 16:15:00 +0000</pubDate>
		<dc:creator>mariano</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://marianoiglesias.com.ar/1/comparing-cakephp-with-other-frameworks/</guid>
		<description><![CDATA[<div>
<p>From IBM&#8217;s new series entitled <a href="http://www.ibm.com/developerworks/library/os-php-fwk1" rel="nofollow" >PHP Frameworks</a> comes our phrase of the day: &#8220;<strong>If you&#8217;ve overheard a conversation about PHP frameworks, that conversation was probably about CakePHP</strong>.&#8221;</p>
</div>


<p>No related posts.</p>


No related posts.]]></description>
			<content:encoded><![CDATA[<div>
<p>From IBM&#8217;s new series entitled <a href="http://www.ibm.com/developerworks/library/os-php-fwk1" rel="nofollow" >PHP Frameworks</a> comes our phrase of the day: &#8220;<strong>If you&#8217;ve overheard a conversation about PHP frameworks, that conversation was probably about CakePHP</strong>.&#8221;</p>
</div>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://marianoiglesias.com.ar/cakephp/comparing-cakephp-with-other-frameworks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk
Database Caching 136/368 queries in 0.413 seconds using disk

Served from: marianoiglesias.com.ar @ 2010-07-30 05:11:14 -->