<?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>Life with CakePHP</title>
	<atom:link href="http://cake.eizoku.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://cake.eizoku.com/blog</link>
	<description>ichikaway blog</description>
	<lastBuildDate>Thu, 19 Jan 2012 14:14:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>FASTER Unit Test</title>
		<link>http://cake.eizoku.com/blog/2012/01/19/faster-unit-test/</link>
		<comments>http://cake.eizoku.com/blog/2012/01/19/faster-unit-test/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 14:14:21 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=193</guid>
		<description><![CDATA[I&#8217;m developing with linux(Vmware guest) on Windows7(host OS).
My laptop has 5400rpm HDD and 8G mem.
My project has many test cases and fixtures, all test cases finished in about 15 minutes  
I wanted to finish group test faster. I guessed large amount of fixture data is bottleneck, since it deletes and restores data many times. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m developing with linux(Vmware guest) on Windows7(host OS).<br />
My laptop has 5400rpm HDD and 8G mem.<br />
My project has many test cases and fixtures, all test cases finished in about 15 minutes <img src='http://cake.eizoku.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>I wanted to finish group test faster. I guessed large amount of fixture data is bottleneck, since it deletes and restores data many times. Disk I/O of Virtual Machine is slower than Host OS&#8217;s one.<br />
At first I changed from HDD to SSD, all test cases finished in under 10 minutes, Wow.</p>
<p>Unfortunately, SSD has a limit on the number of write(update) operation. When group test ran, I worried that it might shorten the life of SSD.<br />
So I moved MySQL data files to Memory(tmpfs) to reduce SSD I/O.<br />
After doing it, group test finished in about 5 minutes <img src='http://cake.eizoku.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Redhat clone Linux like CentOS has tmpfs(on memory filesystem) and mounts it /dev/shm by default.</p>
<p>I made the following scripts,<br />
1.  <strong>onMemoryDeploy.sh</strong>: To move files to memory and make softlink to it<br />
2. <strong>onMemoryMySQL</strong>: init script to run onMemoryDeploy.sh start/stop</p>
<p>Before executing the scripts, I recommend to backup mysql data files.</p>
<pre class="brush: shell;">
/etc/rc.d/init.d/mysql stop
cp -rp /var/lib/mysql /var/lib/mysql-orig
</pre>
<p>Here is the script to move data files to memory and move them back.<br />
/root/onMemoryDeploy.sh  <a href="https://gist.github.com/1633366" target="_blank">script on gist</a></p>
<pre class="brush: shell;">

#!/bin/sh

MYSQL=/etc/rc.d/init.d/mysql

MEMDIR=/dev/shm
MEM_MYSQL=$MEMDIR/mysql

LIBDIR=/var/lib
ORIGDIR=$LIBDIR/mysql

start()
{
  if [ ! -L $MEM_MYSQL ] &amp;&amp; [ -d $ORIGDIR ]; then
    $MYSQL stop
    mv $ORIGDIR $MEMDIR/
    ln -s $MEM_MYSQL $ORIGDIR
    $MYSQL start
  fi
}

stop()
{
  if [ -L $ORIGDIR ] &amp;&amp; [ -d $MEM_MYSQL ]; then
    $MYSQL stop
    rm -f $ORIGDIR
    mv $MEM_MYSQL $LIBDIR/
  fi
}

case &quot;$1&quot; in
  start)
    start
  ;;
  stop)
    stop
  ;;
  *)
    echo &quot;Usage: onMemoryDeply.sh start or stop&quot;
    exit 1
  ;;
esac

exit 0
</pre>
<p>Here is init script(for CentOS) that runs onMemoryDeploy.sh (start/stop) at the OS boot and shutdown.<br />
/etc/rc.d/init.d/onMemoryMySQL  <a href="https://gist.github.com/1633368" target="_blank">script on gist</a></p>
<pre class="brush: shell;">
#!/bin/bash
#
# Startup script for onMemoryMySQL
# chkconfig: 345 85 15
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/usr/bin:/bin

test -f /root/onMemoryDeploy.sh || exit 0

start()
{
  /root/onMemoryDeploy.sh start
  touch /var/lock/subsys/onMemoryMySQL
}

stop()
{
  /root/onMemoryDeploy.sh stop
  rm -f /var/lock/subsys/onMemoryMySQL
}

case &quot;$1&quot; in
  start)
    start
  ;;
  stop)
    stop
  ;;
  *)
    echo &quot;Usage: onMemoryMySQL start or stop&quot;
    exit 1
  ;;
esac

exit 0
</pre>
<p>Then register init script with chkconfig tool.</p>
<pre class="brush: shell;">
/sbin/chkconfig --add onMemoryMySQL
/sbin/chkconfig onMemoryMySQL on
</pre>
<p>Have a good testing time!</p>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/2012/01/19/faster-unit-test/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Performance check of CakePHP1.3.11 and CakePHP2beta</title>
		<link>http://cake.eizoku.com/blog/2011/07/27/performance-check-of-cakephp1-3-11-and-cakephp2beta/</link>
		<comments>http://cake.eizoku.com/blog/2011/07/27/performance-check-of-cakephp1-3-11-and-cakephp2beta/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 03:39:58 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[cakephp]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=166</guid>
		<description><![CDATA[CakePHP1.3.11 and CakePHP2beta  released today. I appreciated great work of the CakeTeam.
CakePHP 1.3.11 and 2.0.0-beta released
CakePHP2 introduces lazy loading and some great futures. I&#8217;m interested in how CakePHP2 faster than CakePHP1.3, so I compared  both performance.
I know CakePHP2 still beta release, maybe it will be faster more and more until the final release.
Measurement Tool
I [...]]]></description>
			<content:encoded><![CDATA[<p>CakePHP1.3.11 and CakePHP2beta  released today. I appreciated great work of the CakeTeam.<br />
<a href="http://bakery.cakephp.org/articles/lorenzo/2011/07/26/cakephp_1_3_11_and_2_0_0-beta_released">CakePHP 1.3.11 and 2.0.0-beta released</a></p>
<p>CakePHP2 introduces lazy loading and some great futures. I&#8217;m interested in how CakePHP2 faster than CakePHP1.3, so I compared  both performance.<br />
I know CakePHP2 still beta release, maybe it will be faster more and more until the final release.</p>
<p><strong>Measurement Tool</strong><br />
I use the Siege(measurement tool) to measure throughput and the XHPref to measure the number of functaion calls.<br />
Before this test, I tried apache ab tool to measure throughput, but it doesn&#8217;t work well. Because it sends the request as HTTP/1.0, Cake2 sends the response as HTTP/1.1.  The ab waits a few seconds for  connection close request.</p>
<p><strong>Server Spec</strong><br />
Server: Dell SC440 Pentium Dual  CPU  E2180  @ 2.00GHz / 2G Memory / SATA HDD<br />
OS: Ubuntu11 64bit<br />
PHP 5.3.5 with APC<br />
Apache 2.2.17</p>
<p><strong>Step</strong><br />
I ran the Siege on same server. Siege option is &#8220;siege -b -c 10 -t 3S&#8221;, it means concurrency 10, access to the server in 3 seconds.<br />
I know it&#8217;s better to run the Siege on another host, but it slightly difficult for me to prepare 2 hosts. This test only compare CakePHP1.3 and Cake2beta on same environment.</p>
<p><strong>SampleApps</strong><br />
I prepare the sample apps of Cake1.3 and Cake2. It&#8217;s very simple code made by bake.<br />
Here is the code.<br />
<a href="https://github.com/ichikaway/CakePHP-PerformanceCheckSample">https://github.com/ichikaway/CakePHP-PerformanceCheckSample</a></p>
<p><strong><br />
Database</strong><br />
I prepare the posts table which has 25,000 records.</p>
<p><strong><br />
Result</strong><br />
Target action is PostController/index which is using pagination.</p>
<p><em>Cake2beta &amp; Cakephp2.0.2<br />
</em></p>
<pre class="brush: text;"> Siege:  40 trans/sec
xhpref: 50msec, 11790calls
</pre>
<p><em><br />
CakePHP1.3.11</em></p>
<pre class="brush: text;">Siege: 29 trans/sec
xhpref: 66msec, 16,931calls
</pre>
<p><strong>Conclusion</strong><br />
Cake2beta and 2.0.2  are  30% faster than CakePHP1.3.10 and reduces 5000 function calls. Awesome!<br />
I guess performance gap is wider on the apps using some DB relations and models.</p>
<p><strong><br />
Extra<br />
</strong>The result of XHpref on CakePHP2 beta. It shows CakeRoute cost is high.  I guess the sample app are using paginator helper, it calls Router class a lot to make the URLs( sort, page number, etc)<br />
The call-graph can be clicked to see original size.</p>
<p><img class="alignnone size-full wp-image-169" title="xhpref-list of Cake2 beta" src="http://cake.eizoku.com/blog/wp-content/uploads/2011/07/xhpref-list.png" alt="xhpref-list of Cake2 beta" width="625" height="390" /></p>
<p><a href="http://cake.eizoku.com/blog/wp-content/uploads/2011/07/callgraph-cake2beta.png"><img class="alignnone size-medium wp-image-170" title="callgraph-cake2beta" src="http://cake.eizoku.com/blog/wp-content/uploads/2011/07/callgraph-cake2beta-300x286.png" alt="callgraph-cake2beta" width="300" height="286" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/2011/07/27/performance-check-of-cakephp1-3-11-and-cakephp2beta/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>checking update of pecl mongo</title>
		<link>http://cake.eizoku.com/blog/2011/07/22/checking-update-of-pecl-mongo/</link>
		<comments>http://cake.eizoku.com/blog/2011/07/22/checking-update-of-pecl-mongo/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 02:35:58 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[cakephp]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=160</guid>
		<description><![CDATA[Recently, pecl mongo driver has been updated a lot.  Today it&#8217;s released version 1.2.2, fixed some segmentation fault problems.
Here is the change log
http://pecl.php.net/package-changelog.php?package=mongo&#38;release=1.2.2
It&#8217;s a little bit difficult for me to catch up the update info, so I made the twitter bot which tweets the update info when pecl mongo driver is updated.
https://twitter.com/#!/pecl_mongo_bot
]]></description>
			<content:encoded><![CDATA[<p>Recently, pecl mongo driver has been updated a lot.  Today it&#8217;s released version 1.2.2, fixed some segmentation fault problems.<br />
Here is the change log<br />
<a href="http://pecl.php.net/package-changelog.php?package=mongo&amp;release=1.2.2">http://pecl.php.net/package-changelog.php?package=mongo&amp;release=1.2.2</a></p>
<p>It&#8217;s a little bit difficult for me to catch up the update info, so I made the twitter bot which tweets the update info when pecl mongo driver is updated.<br />
<a href="https://twitter.com/#!/pecl_mongo_bot">https://twitter.com/#!/pecl_mongo_bot</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/2011/07/22/checking-update-of-pecl-mongo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Misunderstanding of CakePHP beginners or not cake users</title>
		<link>http://cake.eizoku.com/blog/2011/05/19/misunderstanding-of-cakephp-beginner-or-not-cake-users/</link>
		<comments>http://cake.eizoku.com/blog/2011/05/19/misunderstanding-of-cakephp-beginner-or-not-cake-users/#comments</comments>
		<pubDate>Thu, 19 May 2011 04:34:24 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[cakephp]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=143</guid>
		<description><![CDATA[I and @hiromi2424 picked up some misunderstandings of CakePHP, especially cake beginners/not cake users.
Need no SQL knowledge, because Cake model makes SQL statements.
SQL knowledge is so important. We have to understand SQL statements which CakePHP made. It&#8217;s good for performance improvement, debug and avoiding security problems.
Everybody can learn and develop fast, good for PHP noobs
It&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I and <a href="http://twitter.com/hiromi2424">@hiromi2424</a> picked up some misunderstandings of CakePHP, especially cake beginners/not cake users.</p>
<p><strong>Need no SQL knowledge, because Cake model makes SQL statements.</strong><br />
SQL knowledge is so important. We have to understand SQL statements which CakePHP made. It&#8217;s good for performance improvement, debug and avoiding security problems.</p>
<p><strong>Everybody can learn and develop fast, good for PHP noobs</strong><br />
It&#8217;s better to understand OOP and pure PHP before using Cake.</p>
<p><strong>Need a patch to use external libraries</strong><br />
We can use any libraries. Set library files in vendors directory and call App::import(&#8217;Vendor&#8217;,'LibraryName&#8217;)</p>
<p><strong>Slower  so much than pure php</strong><br />
It&#8217;s true only to compare with &#8220;Hello world&#8221; scripts, but production code is more complex. Production code are using many functions and objects, fetching DB records.<br />
In production code, cake applications are slower than pure php one, but not slower so much.<br />
APC(OP code caching) is great solution of performance imporvement.</p>
<p><strong>Can make similar code whoever coding.</strong><br />
It depends on skill and knowledge of MVC.</p>
<p><strong>Don&#8217;t have to care security problems when use SecurityComponent</strong><br />
SecurityComponent detects and protects from CSRF and alteration of post fields.<br />
<a href="http://book.cakephp.org/#!/view/1296/Security-Component">http://book.cakephp.org/#!/view/1296/Security-Component</a><br />
We have to care more security problems, XSS, SQL Injection, ObjectInjection and so on.</p>
<p><strong>DB is mandatory</strong><br />
Set &#8220;false&#8221; to Model::useTable property.<br />
CakePHP FromHelper decides html input type from DB schema, so it&#8217;s better to set input type option of FormHelper::input() without DB.</p>
<p><strong>FormHelper/HtmlHelper is mandatory</strong><br />
You can write view files with pure html tags <img src='http://cake.eizoku.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
It&#8217;s easy to make form screen using helpers, but sometimes the html tags CakePHP made can&#8217;t fit your html/css.<br />
If helpers is annoying you so much, make new helper extending cake helper or <a href="http://bakery.cakephp.org/articles/icedcheese/2008/01/14/overriding-specific-html-tags-before-using-helper-methods">set tags.php</a> or get rid of cake helpers(SecurityComponent needs FromHelper, make CSRF protection by yourself).</p>
<p><strong>Can&#8217;t change bake templates</strong><br />
<a href="http://book.cakephp.org/#!/view/1526/Modify-default-HTML-produced-by-baked-templates"> http://book.cakephp.org/#!/view/1526/Modify-default-HTML-produced-by-baked-templates</a></p>
<p><strong>must follow singular/plural convention</strong><br />
There are some ways to avoid convention. Ex. can use any table name with Model::table property.<br />
We can define our inflection rules using Inflector::rules()<br />
<a href="http://book.cakephp.org/view/953/Inflections">http://book.cakephp.org/view/953/Inflections</a><br />
<a href="http://api.cakephp.org/class/inflector#method-Inflectorrules">http://api.cakephp.org/class/inflector#method-Inflectorrules</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/2011/05/19/misunderstanding-of-cakephp-beginner-or-not-cake-users/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>CakePHP-MongoDB-DboSource update</title>
		<link>http://cake.eizoku.com/blog/2011/04/22/cakephp-mongodb-dbosource-update/</link>
		<comments>http://cake.eizoku.com/blog/2011/04/22/cakephp-mongodb-dbosource-update/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 05:17:31 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[cakephp]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=138</guid>
		<description><![CDATA[I launched new web service using CakePHP and MongoDB. I had to add some functions to CakePHP-MongoDB DboSource, such as using MongoDB update operators, Groupby, Map/Reduce.
I&#8217;ve already pushed bunch of adding code to github. Please git pull and try it 
https://github.com/ichikaway/cakephp-mongodb/
I also write some documents on Wiki of Github.
https://github.com/ichikaway/cakephp-mongodb/wiki/_pages

 How to do distinct
 How to [...]]]></description>
			<content:encoded><![CDATA[<p>I launched new web service using CakePHP and MongoDB. I had to add some functions to CakePHP-MongoDB DboSource, such as using MongoDB update operators, Groupby, Map/Reduce.</p>
<p>I&#8217;ve already pushed bunch of adding code to github. Please git pull and try it <img src='http://cake.eizoku.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<a href="https://github.com/ichikaway/cakephp-mongodb/">https://github.com/ichikaway/cakephp-mongodb/</a></p>
<p>I also write some documents on Wiki of Github.<br />
<a href="https://github.com/ichikaway/cakephp-mongodb/">https://github.com/ichikaway/cakephp-mongodb/wiki/_pages</a></p>
<ul>
<li> <strong><a href="https://github.com/ichikaway/cakephp-mongodb/wiki/How-to-do-distinct">How to do distinct</a></strong></li>
<li> <strong><a href="https://github.com/ichikaway/cakephp-mongodb/wiki/How-to-do-groupby">How to do groupby</a></strong></li>
<li> <strong><a href="https://github.com/ichikaway/cakephp-mongodb/wiki/How-to-do-Map-Reduce">How to do Map Reduce</a></strong></li>
<li> <strong><a href="https://github.com/ichikaway/cakephp-mongodb/wiki/How-to-use-MongoDB-update-operators">How to use MongoDB update operators</a></strong></li>
</ul>
<p>There are API documents in the repository.<br />
<a href="https://github.com/ichikaway/cakephp-mongodb/tree/master/docs">https://github.com/ichikaway/cakephp-mongodb/tree/master/docs</a></p>
<p>Now I&#8217;m testing this DboSource with MongoDB1.6.5 and 1.8.1, pecl mongo1.1.4, CakePHP1.3</p>
<p>I start to work applying it to CakePHP2.0, it&#8217;s in the cake2.0 branch.<br />
<a href="https://github.com/ichikaway/cakephp-mongodb/tree/cake2.0">https://github.com/ichikaway/cakephp-mongodb/tree/cake2.0</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/2011/04/22/cakephp-mongodb-dbosource-update/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Check your spelling mistake and save your life time.</title>
		<link>http://cake.eizoku.com/blog/2011/02/03/check-your-mistakes-and-save-your-life-time/</link>
		<comments>http://cake.eizoku.com/blog/2011/02/03/check-your-mistakes-and-save-your-life-time/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 10:15:04 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=124</guid>
		<description><![CDATA[Hi, I&#8217;m back the blog  
Sometimes I see messages about &#8220;WTF, Could not load behavior by spelling mistake as Model::actAs. waste much time&#8230;&#8221; on the Twitter. Model::actsAs is correct.
I also did such spelling mistake, and wanted to die&#8230;
I want save time and make awesome plugin &#8220;cakephp-MissingDetect-Plugin&#8220;.
This plugin detects spelling mistake of property name as [...]]]></description>
			<content:encoded><![CDATA[<p>Hi, I&#8217;m back the blog <img src='http://cake.eizoku.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Sometimes I see messages about &#8220;WTF, Could not load behavior by spelling mistake as Model::actAs. waste much time&#8230;&#8221; on the Twitter. Model::actsAs is correct.<br />
I also did such spelling mistake, and wanted to die&#8230;</p>
<p>I want save time and make awesome plugin &#8220;<a href="https://github.com/ichikaway/cakephp-MissingDetect-Plugin" target="_blank">cakephp-MissingDetect-Plugin</a>&#8220;.</p>
<p>This plugin detects spelling mistake of property name as follow.</p>
<ul>
<li>Controller::helper ( helpers is correct)</li>
<li>Controller::component (components is correct)</li>
<li>Controller::use (uses is correct)</li>
<li>Model::actAs (actsAs is correct)</li>
</ul>
<p>If you write wrong property name as Controller::component,  you can see alert messages on the top of screen as follow.</p>
<p><img class="alignnone size-full wp-image-130" title="missingdetect-screenshot" src="http://cake.eizoku.com/blog/wp-content/uploads/2011/02/missingdetect-screenshot.jpg" alt="missingdetect-screenshot" width="855" height="524" /></p>
<p>This plugin works only on the debug mode.</p>
<p>It&#8217;s easy to setup, please read the Readme.<br />
<a href="https://github.com/ichikaway/cakephp-MissingDetect-Plugin" target="_blank">https://github.com/ichikaway/cakephp-MissingDetect-Plugin</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/2011/02/03/check-your-mistakes-and-save-your-life-time/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New repository  name of MongoDB driver for CakePHP</title>
		<link>http://cake.eizoku.com/blog/2010/09/17/new-repository-name-of-mongodb-driver-for-cakephp/</link>
		<comments>http://cake.eizoku.com/blog/2010/09/17/new-repository-name-of-mongodb-driver-for-cakephp/#comments</comments>
		<pubDate>Fri, 17 Sep 2010 06:17:30 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[cakephp]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=118</guid>
		<description><![CDATA[I changed repository name of MongoDB driver for CakePHP.
New repository name is &#8220;cakephp-mongodb&#8221;. It is easy to understand the purpose  from repository name  
New repository is here.
http://github.com/ichikaway/cakephp-mongodb
Also, I keep  the old repository for keeping forking list and watcher list.
http://github.com/ichikaway/mongoDB-Datasource
I will often sync repository data  from new to old repository with &#8220;git push &#8211;mirror &#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>I changed repository name of MongoDB driver for CakePHP.</p>
<p>New repository name is &#8220;cakephp-mongodb&#8221;. It is easy to understand the purpose  from repository name <img src='http://cake.eizoku.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>New repository is here.<br />
<a title="http://github.com/ichikaway/cakephp-mongodb" href="http://github.com/ichikaway/cakephp-mongodb">http://github.com/ichikaway/cakephp-mongodb</a></p>
<p>Also, I keep  the old repository for keeping forking list and watcher list.<br />
<a title="http://github.com/ichikaway/mongoDB-Datasource" href="http://github.com/ichikaway/mongoDB-Datasource">http://github.com/ichikaway/mongoDB-Datasource</a></p>
<p>I will often sync repository data  from new to old repository with &#8220;git push &#8211;mirror &#8221; command.<br />
If you are using the old git repository, please change git remote site to the new repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/2010/09/17/new-repository-name-of-mongodb-driver-for-cakephp/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>How to control a cakephp cache duration</title>
		<link>http://cake.eizoku.com/blog/2009/10/07/how-to-control-a-cakephp-cache-duration/</link>
		<comments>http://cake.eizoku.com/blog/2009/10/07/how-to-control-a-cakephp-cache-duration/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 12:07:09 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[cakephp]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=93</guid>
		<description><![CDATA[I&#8217;m using CakePHP1.2.5.
Cache is very powerful function for web pages using heavy SQL queries. If you use the CakePHP default Cache, you can see cache files in the app/tmp/cache directory.
I want to use the Cake Cache function at many points of my system and set different cache duration.
Firstly, check the core.php for using Cache.

//in core.php
Cache::config('default', array('engine' =&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using CakePHP1.2.5.</p>
<p>Cache is very powerful function for web pages using heavy SQL queries. If you use the CakePHP default Cache, you can see cache files in the app/tmp/cache directory.</p>
<p>I want to use the Cake Cache function at many points of my system and set different cache duration.</p>
<p>Firstly, check the core.php for using Cache.</p>
<pre class="brush: php;">
//in core.php
Cache::config('default', array('engine' =&gt; 'File'));
</pre>
<p>This is a sample script using cache function, duration is 1 minute.</p>
<pre class="brush: php;">
class PostController extends AppController {

var $uses = array('Post');

function index() {

$return_data = null;
Cache::set(array('duration' =&gt; '+60 seconds'));
if( ($return_data = Cache::read('PostController-index') ) === false ){

$return_data = $this-&gt;Post-&gt;find('all');
Cache::set(array('duration' =&gt; '+60 seconds'));
Cache::write('PostController-index' , $return_data);
}

$this-&gt;set('data',$return_data);
}
}
</pre>
<p>If there is no cache file(PostController-index),get DB data with the Post model and create cache file with its result. Array data is serialized.<br />
You access same page within 1 minute, cake read cache file(PostController-index)<br />
and return it insted of getting data from the Post model.</p>
<p><strong>Key point is to use Cache::set() before each Cache::read and Cache::write(), we can change cache duration in each point.</strong><br />
<a href="http://book.cakephp.org/view/773/Cache-set" target="_blank">http://book.cakephp.org/view/773/Cache-set</a></p>
<p>Be careful setting cache file name without overlap at each point. I recommend the rule, Class name + function name + parameter.</p>
<p>BTW, we can set Cache::config parameter in Cache::read() and Cache::write().<br />
<a href="http://book.cakephp.org/view/766/Cache-read" target="_blank">http://book.cakephp.org/view/766/Cache-read</a><br />
<a href="http://book.cakephp.org/view/767/Cache-write" target="_blank">http://book.cakephp.org/view/767/Cache-write</a><br />
So, we can define multiple cache config as follow and use it each cache point.</p>
<pre class="brush: php;">
//in core.php
Cache::config('default', array('engine' =&gt; 'File'));
Cache::config('onemin', array('engine' =&gt;'File','duration'=&gt; 60,));
Cache::config('onehour', array('engine' =&gt; 'File','duration'=&gt; 3600,));
</pre>
<pre class="brush: php;">
Cache::read('PostController-index', 'onemin')
Cache::write('PostController-index' , $return_data,'onemin');
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/2009/10/07/how-to-control-a-cakephp-cache-duration/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
		<item>
		<title>How to extend a plugin indirectly</title>
		<link>http://cake.eizoku.com/blog/2009/09/16/how-to-extend-a-plugin/</link>
		<comments>http://cake.eizoku.com/blog/2009/09/16/how-to-extend-a-plugin/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 10:22:33 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=71</guid>
		<description><![CDATA[I’m using CakePHP1.2.4
At times, I want to modify/extend a  plugin indirectly.
How do I do that?
It&#8217;s very simple, only import and inherit.
Here is the plugin(cakeplus) I made on the github.
http://github.com/ichikaway/cakeplus/tree
In this example ,   I use the behavior(add_validation_rule.php) of the cakeplus plugin and modify some method.
1. download the cakeplus plugin, and set in the &#8220;app/plugins&#8221; directory.
2. [...]]]></description>
			<content:encoded><![CDATA[<p>I’m using CakePHP1.2.4<br />
At times, I want to modify/extend a  plugin indirectly.</p>
<p>How do I do that?<br />
It&#8217;s very simple, only import and inherit.</p>
<p>Here is the plugin(cakeplus) I made on the github.<br />
<a href="http://github.com/ichikaway/cakeplus/tree" target="_blank">http://github.com/ichikaway/cakeplus/tree</a></p>
<p>In this example ,   I use the behavior(add_validation_rule.php) of the cakeplus plugin and modify some method.</p>
<p><strong>1. download the cakeplus plugin, and set in the &#8220;app/plugins&#8221; directory.<br />
2. make new directory(cakeplusplus) in the &#8220;app/plugins&#8221;.</strong></p>
<p>Now you can see directories as follow.</p>
<pre class="brush: text;">

plugins/cakeplus/models/behaviors/add_validation_rule.php

plugins/cakeplusplus/models/behaviors/
</pre>
<p><strong>3. create &#8220;ext_add_validation_rule.php&#8221;  file in &#8220;cakeplusplus/models/behaviors/&#8221; directory .</strong></p>
<pre class="brush: php;">

App::import('Model', 'cakeplus.AddValidationRule');
class ExtAddValidationRuleBehavior extends AddValidationRuleBehavior {

}
</pre>
<p><strong>4. Now you can use the &#8220;ExtAddValidationRuleBehavior&#8221; class which has same functions as the &#8220;AddValidationRuleBehavior&#8221; class.</strong></p>
<pre class="brush: php;">
class Post extends AppModel {

var $name = 'Post';

//var $actsAs = array('Cakeplus.AddValidationRule');
var $actsAs = array('Cakeplusplus.ExtAddValidationRule');

}
</pre>
<p><strong>5.If you want to modify or extend, you just override a method of the &#8220;AddValidationRuleBehavior&#8221; class in the &#8220;ExtAddValidationRuleBehavior&#8221; class as follow.</strong><br />
In this example, override the maxLengthJP method and change that function.</p>
<pre class="brush: php;">
App::import('Model', 'cakeplus.AddValidationRule');
class ExtAddValidationRuleBehavior extends AddValidationRuleBehavior {

function maxLengthJP( &amp;$model, $wordvalue, $length ) {
$word = array_shift($wordvalue);

//extend
$length = $length * 2;

return( mb_strlen( $word ) &lt;= $length );
}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/2009/09/16/how-to-extend-a-plugin/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Use placeholder in Model::query() of CakePHP</title>
		<link>http://cake.eizoku.com/blog/2009/08/10/use-placeholders-in-modelquery-of-cakephp/</link>
		<comments>http://cake.eizoku.com/blog/2009/08/10/use-placeholders-in-modelquery-of-cakephp/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 01:25:11 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[model]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=61</guid>
		<description><![CDATA[I&#8217;m using CakePHP1.2.3
Model::query() is very useful for writing SQL statements as follow.

&#60;?php

$this-&#62;Model-&#62;query(&#34;SELECT `Post`.`id` FROM `posts` AS `Post` WHERE `Post`.`id` = 100&#34;, $cachequeries = false);

To avoid SQL Injection, we want to use placeholders instead of embedding user input value in the statement.
We use &#8220;?&#8221; character in the SQL statement, set array data in 2nd parameter of [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using CakePHP1.2.3</p>
<p>Model::query() is very useful for writing SQL statements as follow.</p>
<pre class="brush: php;">
&lt;?php

$this-&gt;Model-&gt;query(&quot;SELECT `Post`.`id` FROM `posts` AS `Post` WHERE `Post`.`id` = 100&quot;, $cachequeries = false);
</pre>
<p>To avoid SQL Injection, we want to use placeholders instead of embedding user input value in the statement.<br />
We use &#8220;?&#8221; character in the SQL statement, set array data in 2nd parameter of the query method.<br />
If 2nd parameter is array data in query method, it executes DboMysql::value() for escape value, using the &#8220;mysql_real_escape_string&#8221; function.</p>
<pre class="brush: php;">
&lt;?php

$sql = &quot;SELECT `Post`.`id` FROM `posts` AS `Post` WHERE `Post`.`id` = ? LIMIT ?&quot;;
$this-&gt;Model-&gt;query($sql, array(100,1), $cachequeries = false);
</pre>
<p>Cake constructs a SQL statement and executes as follow.</p>
<pre class="brush: php;">
SELECT `Post`.`id` FROM `posts` AS `Post` WHERE `Post`.`id` = 100 LIMIT 1
</pre>
<p>References<br />
<a href="http://book.cakephp.org/view/456/query" target="_blank">http://book.cakephp.org/view/456/query</a><br />
<a href="http://en.wikipedia.org/wiki/SQL_injection" target="_blank">http://en.wikipedia.org/wiki/SQL_injection</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/2009/08/10/use-placeholders-in-modelquery-of-cakephp/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

