<?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>botsko &#187; CakePHP</title>
	<atom:link href="http://www.botsko.net/blog/category/cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.botsko.net/blog</link>
	<description>continuing education</description>
	<lastBuildDate>Sat, 24 Jul 2010 21:42:29 +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>Incompatibility between find and saveAll in CakePHP</title>
		<link>http://www.botsko.net/blog/2010/02/25/incompatibility-between-find-and-saveall-in-cakephp/</link>
		<comments>http://www.botsko.net/blog/2010/02/25/incompatibility-between-find-and-saveall-in-cakephp/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 00:49:10 +0000</pubDate>
		<dc:creator>Michael Botsko</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.botsko.net/blog/?p=539</guid>
		<description><![CDATA[In a recent project I wanted to create a separate form for each record from a table using the form helper in CakePHP. After following the instructions found on the net I noticed that there was one big glaring problem. The problem is that when loading the data the find(&#8216;all&#8217;) model function would return data [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent project I wanted to create a separate form for each record from a table using the form helper in CakePHP. After following the instructions found on the net I noticed that there was one big glaring problem.<br />
<span id="more-539"></span><br />
The problem is that when loading the data the find(&#8216;all&#8217;) model function would return data in the following format:</p>
<pre class="brush: php;">Array
(
    [0] =&gt; Array
        (
            [ModelName] =&gt; Array
                (
                    [id] =&gt; 83
                    [field1] =&gt; value1
                    [field2] =&gt; value2
                    [field3] =&gt; value3
                )
        )
)
</pre>
<p>However, the saveAll function accepts data in the following format:</p>
<pre class="brush: php;">Array
(
    [Article] =&gt; Array(
        	[0] =&gt; Array
	        	(
                            [title] =&gt; title 1
                        )
	        [1] =&gt; Array
		        (
                            [title] =&gt; title 2
                        )
                )
)
</pre>
<p>The problem is that they&#8217;re reversed. One has the model name as the root key with an array of records inside and one has an array of model names with records.</p>
<p>There are a few ways to fix this, some even going so far as creating a new behavior or a new extended function of the model class.</p>
<p>Since this was a one-time use for me, I simply needed to switch the array around. The following code does just that:</p>
<pre class="brush: php;">$this-&gt;data = $this-&gt;Modelname-&gt;find('all');

$new_data = array();
foreach ($this-&gt;data as $row) {
	array_push($new_data, $row['Modelname']);
}
$this-&gt;data = array('Modelname'=&gt;$new_data);</pre>
<p>I&#8217;m not to happy about making a round peg fit into a round hole when both were designed by the same folks, but this at least solves the problem. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.botsko.net/blog/2010/02/25/incompatibility-between-find-and-saveall-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Download Old CakePHP Versions</title>
		<link>http://www.botsko.net/blog/2010/01/08/download-old-cakephp-versions/</link>
		<comments>http://www.botsko.net/blog/2010/01/08/download-old-cakephp-versions/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 18:28:36 +0000</pubDate>
		<dc:creator>Michael Botsko</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.botsko.net/blog/?p=509</guid>
		<description><![CDATA[I&#8217;m not really a fan of CakePHP, but I work with it often and understand it well. I recently had a project where a previous developer modified random cakephp library files directly, thus making it difficult for me to upgrade the framework. I determined that the version currently in use was 1.2.1.8004, which surprisingly is [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not really a fan of CakePHP, but I work with it often and understand it well. I recently had a project where a previous developer modified random cakephp library files directly, thus making it difficult for me to upgrade the framework.<br />
<span id="more-509"></span><br />
I determined that the version currently in use was 1.2.1.8004, which surprisingly is no longer available for download from the <a href="http://www.cakephp.org">CakePHP</a> website. I even jumped onto IRC to ask folks where older versions were kept and no one was able to help.</p>
<p>I finally just pulled the cakephp source from the <a href="http://github.com/cakephp/cakephp1x">github account</a>. I knew from the comments in the cakephp release that it was from 1/16/2009, so I looked for any commits that occured that day.</p>
<p>I determined that <a href="http://github.com/cakephp/cakephp1x/commit/9f83e96fb9ddaf69c9b9df51b69dcf115c41dc01">9f83e96</a> was the official tag before the release. Once you have the cakephp repository cloned to your local machine, it&#8217;s easy to simply checkout that specific commit.</p>
<p><code>$ git clone git://github.com/cakephp/cakephp1x.git<br />
$ cd cakephp1x<br />
$ git checkout 9f83e96</code></p>
<p>Voila! Depending on what you want to do with this code, you can simply zip it up and go or create a new git branch.</p>
<p><code>$ git checkout -b your-branch-name</code></p>
<p>The CakePHP team really needs to restore an archive with old releases, or tell me where they&#8217;ve hidden it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.botsko.net/blog/2010/01/08/download-old-cakephp-versions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
