<?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=rss2" rel="self" type="application/rss+xml" />
	<link>http://cake.eizoku.com/blog</link>
	<description>ichikaway : japanese baker blog</description>
	<lastBuildDate>Thu, 08 Oct 2009 02:35:11 +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>How to control a cakephp cache duration</title>
		<link>http://cake.eizoku.com/blog/?p=93</link>
		<comments>http://cake.eizoku.com/blog/?p=93#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/?feed=rss2&amp;p=93</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to extend a plugin indirectly</title>
		<link>http://cake.eizoku.com/blog/?p=71</link>
		<comments>http://cake.eizoku.com/blog/?p=71#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/?feed=rss2&amp;p=71</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use placeholder in Model::query() of CakePHP</title>
		<link>http://cake.eizoku.com/blog/?p=61</link>
		<comments>http://cake.eizoku.com/blog/?p=61#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/?feed=rss2&amp;p=61</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CakePHP in Japan</title>
		<link>http://cake.eizoku.com/blog/?p=41</link>
		<comments>http://cake.eizoku.com/blog/?p=41#comments</comments>
		<pubDate>Fri, 24 Jul 2009 02:33:49 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[japan]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=41</guid>
		<description><![CDATA[Cakephp Bakers are increasing rapidly in Japan. I think there are some reasons as follow.
1. Books
There are over 7  japanese books for CakePHP!  Japanese Book is very important factor to get many developers in Japan.
Some books for beginner(XAMP install, bake, create small applications), some books for intermediate or higher level( component, behavior, helper, test cases, [...]]]></description>
			<content:encoded><![CDATA[<p><span><span>Cakephp Bakers are increasing rapidly in Japan</span></span>. I think there are some reasons as follow.</p>
<p><strong>1. Books</strong></p>
<p>There are over 7  japanese books for CakePHP!  Japanese Book is very important factor to get many developers in Japan.</p>
<p>Some books for beginner(XAMP install, bake, create small applications), some books for intermediate or higher level( component, behavior, helper, test cases, mobile site, Routing, callbacks, create practical applications).</p>
<p>You can see book covers followin link (Japanese web site).</p>
<p><a href="http://d.hatena.ne.jp/keyword/CakePHP">http://d.hatena.ne.jp/keyword/CakePHP</a></p>
<p><strong>2. Community Site<br />
</strong></p>
<p>Japanese cakephp community ( <a href="http://cakephp.jp">http://cakephp.jp</a> ).  There is <a href="http://cakephp.jp/modules/newbb/">a good forum</a> on its web site. Many bakers ask questions and argue many topics in japanese , very usefull for not only beginners but also higher level users. Sometimes find some bugs in that discussion, then post tickets for trac.cakephp.org.</p>
<p><strong>3. Events</strong></p>
<p>Now in japan,  it is boom of meet-up for study( Programming, Design, Server Operation, etc ). In these meet-up, many different company people come together after working or in a holiday, and discuss some topics, often talking with drinking beer <img src='http://cake.eizoku.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>There were some CakePHP meet-up in  Tokyo, Osaka and Fukuoka. This is a report of CakePHP meet-up at Tokyo. <a href="http://bakery.cakephp.org/articles/view/report-cakephp-meet-up-at-tokyo-4th">http://bakery.cakephp.org/articles/view/report-cakephp-meet-up-at-tokyo-4th</a></p>
<p>In these meet-up, 50 or 100 japanese bakers come together, so nice events.</p>
<p><strong>4. Blogs</strong></p>
<p>There are many japanese baker&#8217;s blogs. Some bakers post good articles ( how to solve a problem, find bug, explain or make compoent, behavior, plugins,etc). If we have problems, we can find japanese articles of that resolutions  easily with the google.</p>
<p>It is very important to get many japanese information and resolutions easily.</p>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/?feed=rss2&amp;p=41</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Validation error message i18n</title>
		<link>http://cake.eizoku.com/blog/?p=30</link>
		<comments>http://cake.eizoku.com/blog/?p=30#comments</comments>
		<pubDate>Thu, 23 Jul 2009 02:57:47 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=30</guid>
		<description><![CDATA[In a Model, we can define validation error message as follow

&#60;?php
class User extends AppModel {
	var $validate = array(
		'email' =&#62; array(
			&#34;email_invalid&#34; =&#62; array('rule' =&#62; VALID_EMAIL,
				'required' =&#62; true,
				'message'    =&#62;    'Invalid Email address.',
	),

But, can not use i18n function __() for validation error messages .
This is a solution to do it.

&#60;?php
class AppModel extends [...]]]></description>
			<content:encoded><![CDATA[<p>In a Model, we can define validation error message as follow</p>
<pre class="brush: php;">
&lt;?php
class User extends AppModel {
	var $validate = array(
		'email' =&gt; array(
			&quot;email_invalid&quot; =&gt; array('rule' =&gt; VALID_EMAIL,
				'required' =&gt; true,
				'message'    =&gt;    'Invalid Email address.',
	),
</pre>
<p>But, can not use i18n function __() for validation error messages .<br />
This is a solution to do it.</p>
<pre class="brush: php;">
&lt;?php
class AppModel extends Model {

	//Validation message i18n
	function invalidate($field, $value = true){
		parent::invalidate($field, $value);
		$this-&gt;validationErrors[$field] = __($value, true);
	}
}
</pre>
<p>Model::invalidate method is called in validation processing(Model::validates , Model::invalidFields).<br />
This solution override Model::invalidate and set __() in each error messsage.</p>
<p>Then, you write po file of each language, language of validation error messages change depending on browser language configuration.</p>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/?feed=rss2&amp;p=30</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>SQL syntax highlighting for Debug_kit</title>
		<link>http://cake.eizoku.com/blog/?p=20</link>
		<comments>http://cake.eizoku.com/blog/?p=20#comments</comments>
		<pubDate>Wed, 08 Jul 2009 06:29:44 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[debugkit]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=20</guid>
		<description><![CDATA[I make SQL syntax highlighting feature for sql log panel of Debug_kit. I use GeSHi for syntax highlight.
Source code download here(include GeSHi).
You can see diff code here.
screen shot



]]></description>
			<content:encoded><![CDATA[<p>I make SQL syntax highlighting feature for sql log panel of Debug_kit. I use <a href="http://qbnz.com/highlighter/" target="_blank">GeSHi</a> for syntax highlight.</p>
<p><a href="http://git2zip.com/thechaw/ichikawa/" target="_blank">Source code download here</a>(include GeSHi).</p>
<p>You can see <a href="http://thechaw.com/forks/ichikaway/debug_kit/commits/view/16e48f39ce72d6b09a3854ec878c5b69e1529daa" target="_blank">diff code here</a>.</p>
<p>screen shot<br />
<a href="http://f.hatena.ne.jp/images/fotolife/c/cakephper/20090707/20090707143041.jpg" target="_blank"><br />
<img class="alignnone size-full wp-image-21" title="debugkit_geshi_sql3" src="http://cake.eizoku.com/blog/wp-content/uploads/2009/07/debugkit_geshi_sql3.jpg" alt="debugkit_geshi_sql3" width="" height="" /><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/?feed=rss2&amp;p=20</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello Baker!</title>
		<link>http://cake.eizoku.com/blog/?p=4</link>
		<comments>http://cake.eizoku.com/blog/?p=4#comments</comments>
		<pubDate>Wed, 08 Jul 2009 03:22:36 +0000</pubDate>
		<dc:creator>ichikaway</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cake.eizoku.com/blog/?p=4</guid>
		<description><![CDATA[test

&#60;?php echo &#34;Hello baker!&#34;; ?&#62;

]]></description>
			<content:encoded><![CDATA[<p>test</p>
<pre class="brush: php;">
&lt;?php echo &quot;Hello baker!&quot;; ?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cake.eizoku.com/blog/?feed=rss2&amp;p=4</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
