<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web Plant Media &#187; CakePHP</title>
	<atom:link href="http://www.webplantmedia.com/category/cakephp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webplantmedia.com</link>
	<description>Lubbock Web Design and Web Development</description>
	<lastBuildDate>Wed, 28 Mar 2012 21:19:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Cache Problem in CakePHP</title>
		<link>http://www.webplantmedia.com/cakephp/2010/09/cache-problem-in-cakephp/</link>
		<comments>http://www.webplantmedia.com/cakephp/2010/09/cache-problem-in-cakephp/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 15:56:13 +0000</pubDate>
		<dc:creator>ChrisB</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.webplantmedia.com/?p=440</guid>
		<description><![CDATA[I recently had a problem on our website with caching in our CakePHP framework. We initially had caching turned on. And then we started noticing when we submitted a form, our changes wound not be updated until we manually refreshed the page. So let&#8217;s say I have a row of users. I choose to delete [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a problem on our website with caching in our CakePHP framework. We initially had caching turned on. And then we started noticing when we submitted a form, our changes wound not be updated until we manually refreshed the page.</p>
<p>So let&#8217;s say I have a row of users. I choose to delete one of the users. I click on delete, hit submit and cake removes that user from my table. Cake then redirects me back to same page, but the deleted user is still listed on our page. Once we manually hit the refresh button on our browser, then our deleted user disappears from our form page.</p>
<p>We scratched our heads and tried figuring out why this was happening. We turned off all caching and even added the &lt;cake:nocache&gt; tag. No matter what we did, we could not get rid of the problem.</p>
<p>After much research, we realized that the browser itself was actually caching the previous form page. So we added this snippet of code to our app controller.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">disableCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This is used to tell the user’s browser not to cache the results of the current request. The headers sent to this effect are:</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">Expires: Mon, 26 Jul 1997 05:00:00 GMT
Last-Modified: [current datetime] GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache</pre></div></div>

<p>I hope this saves you some time. If you find a better way fixing this problem, please leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webplantmedia.com/cakephp/2010/09/cache-problem-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Select Field Names in Table in CakePHP</title>
		<link>http://www.webplantmedia.com/cakephp/2010/04/how-to-select-field-names-in-table-in-cakephp/</link>
		<comments>http://www.webplantmedia.com/cakephp/2010/04/how-to-select-field-names-in-table-in-cakephp/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 07:33:27 +0000</pubDate>
		<dc:creator>ChrisB</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.webplantmedia.com/?p=323</guid>
		<description><![CDATA[In php you can use mysql_field_name to get the field name of the specified field in a result. Someone asked me the following question. If Employee table has three rows id,name and address. How do we fetch those names (id,name,address) using sql query in cakephp? First of all, you can&#8217;t actually use mysql_field_name() in cakephp. [...]]]></description>
			<content:encoded><![CDATA[<p>In php you can use <a href="http://php.net/manual/en/function.mysql-field-name.php" target="_blank">mysql_field_name</a>  to get the field name of the specified field in a result. Someone asked me the following question.</p>
<blockquote><p>If Employee table has three rows id,name and address. How do we fetch those names (id,name,address) using sql query in cakephp?</p></blockquote>
<p>First of all, you can&#8217;t actually use mysql_field_name() in cakephp. But there are workarounds. Say you want to find the field names of the the table &#8216;Post&#8217;. Here is what you can do.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'all'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> Set<span style="color: #339933;">::</span><span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/0/Post'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$field_names</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_keys</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Post'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$field_names</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The result of the print statements will display the following</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">Array</span>
<span style="color: #009900;">&#40;</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
        <span style="color: #009900;">&#40;</span>
            <span style="color: #009900;">&#91;</span>Post<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
                <span style="color: #009900;">&#40;</span>
                    <span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">2</span>
                    <span style="color: #009900;">&#91;</span>title<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> A title once again
                    <span style="color: #009900;">&#91;</span>body<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> And the post body follows<span style="color: #339933;">.</span>
                    <span style="color: #009900;">&#91;</span>created<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">2010</span><span style="color: #339933;">-</span><span style="color: #208080;">02</span><span style="color: #339933;">-</span><span style="color:#800080;">08</span> <span style="color: #208080;">07</span><span style="color: #339933;">:</span><span style="color: #cc66cc;">48</span><span style="color: #339933;">:</span><span style="color: #208080;">03</span>
                    <span style="color: #009900;">&#91;</span>modified<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> 
                <span style="color: #009900;">&#41;</span>
&nbsp;
        <span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #990000;">Array</span>
<span style="color: #009900;">&#40;</span>
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> id
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> title
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> body
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> created
    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> modified
<span style="color: #009900;">&#41;</span></pre></div></div>

<p>I hope this helps. Feel free to comment on this page. I&#8217;ll get notified immediately. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webplantmedia.com/cakephp/2010/04/how-to-select-field-names-in-table-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to Save Multiple Models in CakePHP</title>
		<link>http://www.webplantmedia.com/cakephp/2010/03/how-to-save-multiple-models-in-cakephp/</link>
		<comments>http://www.webplantmedia.com/cakephp/2010/03/how-to-save-multiple-models-in-cakephp/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 07:19:31 +0000</pubDate>
		<dc:creator>ChrisB</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.webplantmedia.com/?p=145</guid>
		<description><![CDATA[It&#8217;s inevitable that you will have a form where you will need to save multiple models at once. Here is a small hack on how you might do that. if &#40;!empty&#40;$this-&#62;data&#41;&#41; &#123; $this-&#62;ModelName-&#62;create&#40;&#41;; $allSaved = true; &#160; foreach&#40;$this-&#62;data as $model =&#62; $data&#41; &#123; switch &#40;$model&#41; &#123; case 'ModelName1' : /*manipulate ModelName1 data here*/ if &#40;!$this-&#62;ModelName1-&#62;saveAll&#40;$this-&#62;data&#91;'ModelName1'&#93;&#41;&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s inevitable that you will have a form where you will need to save multiple models at once. Here is a small hack on how you might do that.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ModelName</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$allSaved</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$model</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$model</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ModelName1'</span> <span style="color: #339933;">:</span>
                <span style="color: #666666; font-style: italic;">/*manipulate ModelName1 data here*/</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ModelName1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveAll</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ModelName1'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #000088;">$allSaved</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ModelName2'</span> <span style="color: #339933;">:</span>
                <span style="color: #666666; font-style: italic;">/*manipulate ModelName2 data here*/</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ModelName2</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveAll</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ModelName2'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                    <span style="color: #000088;">$allSaved</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$allSaved</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">/*Print Success Message*/</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.webplantmedia.com/cakephp/2010/03/how-to-save-multiple-models-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Write Custom SQL in CakePHP</title>
		<link>http://www.webplantmedia.com/cakephp/2010/03/write-custom-sql-in-cakephp/</link>
		<comments>http://www.webplantmedia.com/cakephp/2010/03/write-custom-sql-in-cakephp/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 07:05:19 +0000</pubDate>
		<dc:creator>ChrisB</dc:creator>
				<category><![CDATA[CakePHP]]></category>

		<guid isPermaLink="false">http://www.webplantmedia.com/?p=142</guid>
		<description><![CDATA[There may be a time when you want to simply just write your own custom sql in cakephp. Now, cakephp doesn&#8217;t want you to do this. The find() and save() calls should be able to do everything you need to do. But, I&#8217;ve found it useful to write custom sql queries for testing purposes. Here [...]]]></description>
			<content:encoded><![CDATA[<p>There may be a time when you want to simply just write your own custom sql in cakephp. Now, cakephp doesn&#8217;t want you to do this. The find() and save() calls should be able to do everything you need to do. But, I&#8217;ve found it useful to write custom sql queries for testing purposes. Here is how you do it.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ModelName</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM TableName&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.webplantmedia.com/cakephp/2010/03/write-custom-sql-in-cakephp/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Object Caching 311/327 objects using disk: basic

Served from: www.webplantmedia.com @ 2012-05-18 07:25:26 -->
