<?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/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>おれ最前線ねっと &#187; Lang</title>
	<atom:link href="http://ore.saizensen.net/archives/category/lang/feed" rel="self" type="application/rss+xml" />
	<link>http://ore.saizensen.net</link>
	<description>イェ〜〜ィ。見てる〜〜〜？？</description>
	<lastBuildDate>Tue, 12 Jul 2011 06:31:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/category/lang/feed" />
		<item>
		<title>[Ubuntu]Ubuntu8.10へObjective-C環境をインストールしてみた。[Objective-C]</title>
		<link>http://ore.saizensen.net/archives/200</link>
		<comments>http://ore.saizensen.net/archives/200#comments</comments>
		<pubDate>Fri, 06 Feb 2009 09:15:56 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[Lang]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/?p=200</guid>
		<description><![CDATA[1週間くらい前からObjective-Cを触り始めて見ました。Cすら一度も触ったことないから分からんことだらけですけど・・・ で、前は初代Macbookを持っていたんですけどThinkpadX61へ乗り換えと同時に手放し [...]]]></description>
			<content:encoded><![CDATA[				<p>1週間くらい前から<strong>Objective-C</strong>を触り始めて見ました。Cすら一度も触ったことないから分からんことだらけですけど・・・<br />
				で、前は初代Macbookを持っていたんですけどThinkpadX61へ乗り換えと同時に手放してしまったので<br />
				X61上の<strong>Ubuntu8.10でObjective-C</strong>を学習しときます。<br />
				学習用に「<strong>詳解Objective-C2.0</strong>」という本を用意しました。この本を終えたら新しくMacbookを購入し直そうと思います。<br />
				iPhoneだって持ってないんですけどね・・・・</p>
				<div style="text-align: center;">
				<div class="imageframe centered" style="width: 200px;"><a title="詳解Objective-C2.0" rel="lightbox[pics200]" href="http://ore.saizensen.net/wp-content/uploads/2009/02/51kl8v91cel_ss400_.jpg"><img class="attachment wp-att-203" src="http://ore.saizensen.net/wp-content/uploads/2009/02/51kl8v91cel_ss400_.thumbnail.jpg" alt="" width="200" height="200" /></a></p>
				<div class="imagecaption"><a href="http://www.amazon.co.jp/gp/product/4797346809/ref=sib_rdr_dp">詳解Objective-C2.0</a></div>
				</div>
				</div>
				<p>とりあえずいつも通り、<strong>Ubuntu8.10へのObjective-C環境のインストール方法</strong>をまとめておきます。</p>
				<ol>
				<li>いろいろとインストール。こんだけ入れると取り合えず<strong>Objective-C</strong>の環境は整います。
				<pre>sudo apt-get install build-essential gobjc gobjc-multilib libgnustep-base-dev gnustep gnustep-devel gnustep-dl2 doxygen</pre>
</li>
<li>↑だけインストールするだけだとNSObjectが使えないので↓も行う。（Objective-C2.0本を進めていると、どうしてもNSObjectが必要だったので・・・つかNSObjectが使えないとretain、releaseとかが無い！）<br />
・Foundationフレームワークを使えるようにパスが通るディレクトリへリンクを張る為に↓を作成。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #007800;">frompath</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>GNUstep
<span style="color: #007800;">topath</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>gcc<span style="color: #000000; font-weight: bold;">/</span>i486-linux-gnu<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4.3</span><span style="color: #000000; font-weight: bold;">/</span>include
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #ff0000;">&quot;AppKit&quot;</span> <span style="color: #ff0000;">&quot;Cocoa&quot;</span> <span style="color: #ff0000;">&quot;Cynthiune&quot;</span> <span style="color: #ff0000;">&quot;DBKit&quot;</span> <span style="color: #ff0000;">&quot;EOAccess&quot;</span> <span style="color: #ff0000;">&quot;EOControl&quot;</span> <span style="color: #ff0000;">&quot;EOInterface&quot;</span> <span style="color: #ff0000;">&quot;EOModeler&quot;</span> <span style="color: #ff0000;">&quot;FSNode&quot;</span> <span style="color: #ff0000;">&quot;Foundation&quot;</span> <span style="color: #ff0000;">&quot;Frameworks&quot;</span> <span style="color: #ff0000;">&quot;GNUMail&quot;</span> <span style="color: #ff0000;">&quot;GNUstepBase&quot;</span> <span style="color: #ff0000;">&quot;GNUstepGUI&quot;</span> <span style="color: #ff0000;">&quot;GormCore&quot;</span> <span style="color: #ff0000;">&quot;GormObjCHeaderParser&quot;</span> <span style="color: #ff0000;">&quot;GormPrefs&quot;</span> <span style="color: #ff0000;">&quot;HighlighterKit&quot;</span> <span style="color: #ff0000;">&quot;Inspector&quot;</span> <span style="color: #ff0000;">&quot;InterfaceBuilder&quot;</span> <span style="color: #ff0000;">&quot;Operation&quot;</span> <span style="color: #ff0000;">&quot;PostgreSQLEOAdaptor&quot;</span> <span style="color: #ff0000;">&quot;ProjectCenter&quot;</span> <span style="color: #ff0000;">&quot;Renaissance&quot;</span> <span style="color: #ff0000;">&quot;TalkSoupBundles&quot;</span> <span style="color: #ff0000;">&quot;WizardKit&quot;</span> <span style="color: #ff0000;">&quot;gnustep&quot;</span>
<span style="color: #000000; font-weight: bold;">do</span>
	<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #007800;">$frompath</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$i</span> <span style="color: #007800;">$topath</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>
				
				<p>リンク張っているのは/usr/include/GNUstep以下にある全てをリンクしてるだけです。勉強始めたばっかなんで各ファイルにどんな機能、役割があんのかは全くもって不明ですwww<br />
				で、作成したスクリプトファイルを実行。</p>
				<pre>sudo sh /保存したスクリプトのパス/link_libobjc.sh</pre>
</li>
</ol>
<p>以上で<strong>Ubuntu8.10へのObjective-C環境構築</strong>はおわりです。<br />
これで「<strong>詳解Objective-C2.0</strong>」に載ってるソースそのままで動くと思います。（どっかで躓いたらまた記事修正しときます。）<br />
最後に、Ubuntu8.10上でソースをコンパイルする時なんですが</p>
<pre>gcc ソースファイル名 -o コンパイル後ファイル名 -lobjc -lgnustep-base</pre>
				<p>としてください。<br />
				あと、分からんというか面倒くさいというか、mainソースファイルから自前で作成したヘッダファイル(.hファイル)を読み込んでコンパイルするとき</p>
				<pre>gcc ソースファイル名 -o コンパイル後ファイル名 -lobc -lgnustep-base -include ヘッダファイル名1 -include ヘッダファイル名2</pre>
<p>みたいにしないとコンパイル出来んのですが、複数のヘッダファイルを読み込むとき、「-include ヘッダファイル名」を何度も書くのは面倒くさいですな・・・なんか良い方法あるんですかねぇ？</p>
<p><strong>2009/02/17 追記</strong><br />
Tomuteさんコメントありがとうございます。助かりました。<br />
<strong>詳解Objective-C2.0</strong>を読み進めていると、Tomuteさんのブログにも書いてるようにコンパイル時に</p>
<pre> error: cannot find interface declaration for ‘NXConstantString</pre>
				<p>とエラー返してくるので、コンパイルオプションに&#8221;-fconstant-string-class=NSConstantString&#8221;を追加しないとダメみたいです。またTomuteさんに教えてもらった-Iオプションも追加。</p>
				<pre>gcc ソースファイル名1 ソースファイル名2 ソースファイル名3 -o コンパイル後ファイル名 -lobjc -lgnustep-base -I/指定ディレクトリ -fconstant-string-class=NSConstantString</pre>
<p>こんな風にするみたいです。</p>
<p>< 参考にしたサイト： <a href="http://d.hatena.ne.jp/tomute/20090112/1231809116">Tomute’s Notes [Linux] Ubuntu LinuxでObjective-C></p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/200/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/200" />
	</item>
		<item>
		<title>[CakePHP]CakePHP1.2のfind時にDBカラムを型変換して検索条件にする方法。</title>
		<link>http://ore.saizensen.net/archives/197</link>
		<comments>http://ore.saizensen.net/archives/197#comments</comments>
		<pubDate>Mon, 22 Dec 2008 07:56:51 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/?p=197</guid>
		<description><![CDATA[$cond&#91;&#34;to_char(Hoge.date, 'YYYYMMDD') LIKE '%20081222%' and \&#34;Hoge\&#34;.\&#34;id\&#34;&#34; [...]]]></description>
			<content:encoded><![CDATA[				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$cond</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;to_char(Hoge.date, 'YYYYMMDD') LIKE '%20081222%' and <span style="color: #000099; font-weight: bold;">\&quot;</span>Hoge<span style="color: #000099; font-weight: bold;">\&quot;</span>.<span style="color: #000099; font-weight: bold;">\&quot;</span>id<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$hoge</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;Hoge&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>こんな感じで。<br />
私、PostgreSQLしか使わんのでMySQLはよく分からんけど、<br />
どっちもDB関数使いたければ検索条件のカラム名の前に突っ込んだらイイんじゃないかと。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/197/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/197" />
	</item>
		<item>
		<title>[CakePHP]CakePHP1.2の日付選択リストの月表記を英語から数字へ変更する方法。[FormHelper]</title>
		<link>http://ore.saizensen.net/archives/191</link>
		<comments>http://ore.saizensen.net/archives/191#comments</comments>
		<pubDate>Mon, 22 Dec 2008 07:53:16 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/?p=191</guid>
		<description><![CDATA[&#60; ?php $form-&#62;options&#91;'month'&#93; = array_combine&#40;range&#40;1, 12&#41;, range&#40;1, 12&#41;&#4 [...]]]></description>
			<content:encoded><![CDATA[				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'month'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_combine</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">range</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">range</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">year</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hoge.date&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>年
<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">month</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hoge.date&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>月
<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">day</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hoge.date&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>日</pre></div></div>
				
				<p><a href="http://fdays.blogspot.com/2008/09/form-select-echo-form-mdy-none.html"><br />
				floatingdays &#8211; CakePHP 1.2 のFormHelperで日付選択リストを作る </a></p>
				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">datetime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cal'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'YMD'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'NONE'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'monthNames'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>っていう方法もそういえば有りましたねぇ。ということでメモメモ。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/191/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/191" />
	</item>
		<item>
		<title>[Ubuntu]Ubuntu8.10でRailsをアップデートしたよ。[Rails]</title>
		<link>http://ore.saizensen.net/archives/187</link>
		<comments>http://ore.saizensen.net/archives/187#comments</comments>
		<pubDate>Fri, 12 Dec 2008 02:51:05 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[Lang]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[インストールメモ]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/?p=187</guid>
		<description><![CDATA[Rails2.1.0をインストールしていたけど、新しいRails2.2.2をインストールするよ。 rubygemsのバージョンをアップデートする。 % sudo gem install rubygems-update % [...]]]></description>
			<content:encoded><![CDATA[				<p><strong>Rails2.1.0</strong>をインストールしていたけど、新しい<strong>Rails2.2.2</strong>をインストールするよ。</p>
				<ol>
				<li><strong>rubygems</strong>のバージョンをアップデートする。
				<pre>
% sudo gem install rubygems-update
% sudo gem update rubygems-update
</pre>
				</li>
				<li><strong>Rails</strong>をインストールする。
				<pre>% sudo gem update rails</pre>
<p>MySQLのドライバーがねーよ！とか言われた人はMysqlのドライバーもインストールする。↓</p>
<pre>
%sudo apt-get install libmysqlclient15-dev
%sudo gem install mysql
</pre>
				<p>他にもインストールしたいのあれば参考に→<a href="http://ore.saizensen.net/archives/148">[Ubuntu]Ubuntu8.10へRailsをインストールしたよ。[Rails]</a>
				</li>
				<li>既存のアプリケーションが利用している<strong>Rails</strong>のバージョンを上げる。
				<pre>
% cd /var/www/rails/app  ## Railsアプリケーションまで移動する。移動先は自分の環境に合わせて
% vi config/environment.rb
RAILS_GEM_VERSION = '2.1.0'
↓ ## 使いたいRailsのバージョンへ修正。
RAILS_GEM_VERSION = '2.2.2'
% rake rails:update
</pre>
				</li>
				</ol>
				<p>以上で<strong>Rails</strong>のバージョンが上がったよと。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/187/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/187" />
	</item>
		<item>
		<title>[CentOS]CentOS5の「PHP、MySQL、PostgreSQL」のバージョンをYumでアップデートする。</title>
		<link>http://ore.saizensen.net/archives/163</link>
		<comments>http://ore.saizensen.net/archives/163#comments</comments>
		<pubDate>Wed, 26 Nov 2008 16:45:39 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[DB]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PostGIS]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[インストールメモ]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/?p=163</guid>
		<description><![CDATA[なんかサーバーを弄ってたら、PHPとかMySQLとかPostgresのバージョンを無性に上げたくなってきたからバージョンアップした。全部、自前でbuildなんてやってられんので全てYumで管理します。 CentOSのリポ [...]]]></description>
			<content:encoded><![CDATA[				<p>なんかサーバーを弄ってたら、PHPとかMySQLとかPostgresのバージョンを無性に上げたくなってきたからバージョンアップした。全部、自前でbuildなんてやってられんので全てYumで管理します。<br />
				CentOSのリポジトリのPHPなんて5.1.6とかPostgresが8.1とか・・・ねぇ？って感じだったのでつい・・・<br />
				ということでインストールメモ開始。このブログ、インストールメモ専門になってきたな・・・</p>
				<ol>
				<li>まず標準のCentOSのリポジトリからPHP、MySQL、PostgreSQLを除外する.。
				<pre>
# vi /etc/yum.repos.d/CentOS-Base.repo
[base] ## [base]の項目に↓を追加
exclude=postgresql* php* mysql*
[updates] ## [updates]の項目にも↓を追加
exclude=postgresql* php* mysql*
</pre>
				</li>
				<li>PHPとMySQLをアップデートする用にまずリポジトリ追加。
				<pre>
# rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
# vi /etc/yum.repos.d/utterramblings.repo ## ←のファイル作って以下の内容で保存。
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
</pre>
				</li>
				<li>PostgreSQLをアップデートする用にやっぱりまずはリポジトリ追加。
				<pre>
# wget http://yum.pgsqlrpms.org/reporpms/8.3/pgdg-centos-8.3-5.noarch.rpm
# rpm -ivh pgdg-centos-8.3-5.noarch.rpm
</pre>
				</li>
				<li>PHPとMySQLとPostgreSQLをアップデート。
				<pre>
# yum update
</pre>
				<ul>
				<li><strong>※ x86_64な環境の人で、既にMySQLをインストールしている人は一度削除してからインストールしなおしてください。(mysql、mysql-devel、mysql-server)</strong>
				<pre>
# yum -y remove mysql mysql-devel mysql-server
# yum -y install mysql mysql-devel mysql-server
</pre>
				</li>
				<li><strong>※ 既にPostgreSQLをインストール済の人で「古いバージョンの〜〜〜アップグレードする必要があります。」と言われた場合</strong>
				<ol>
				<li>dataを削除、またはリネーム
				<pre># mv /var/lib/pgsql/data /var/lib/pgsql/data.old</pre>
</li>
<li>DB初期化
<pre># /etc/init.d/postgresql initdb</pre>
				</li>
				<li>PostgreSQL再起動
				<pre># /etc/init.d/postgresql restart</pre>
</li>
</ol>
</li>
</ul>
</li>
<li>リポジトリ追加したらyumでXcacheとかPostGISがインストールできるようになってたからインストールした。
<pre># yum -y install php-xcache postgis</pre>
				</li>
				</ol>
				<p>各設定は以下を参考に。Ubuntu用に書いたけどほとんどいっしょなので。</p>
				<ul>
				<li><a href="http://ore.saizensen.net/archives/122">[Ubuntu]Ubuntu8.10へApache、PHP、MySQL、PostgreSQLをインストールする。[LAMP]</a></li>
				<p>php.ini ： /etc/php.ini<br />
				my.cnf ： /etc/my.cnf<br />
				postgresql.conf ： /var/lib/pgsql/data/postgresql.conf<br />
				pg_hba.conf ： /var/lib/pgsql/data/pg_hba.conf</p>
				<li><a href="http://ore.saizensen.net/archives/113">[PHP]CentOSへXCacheをインストールしたメモ。[XCache]</a><br />
				xcache.ini ： /etc/php.d/xcache.ini
				</li>
				<li><a href="http://ore.saizensen.net/archives/160">[Ubuntu]Ubuntu8.10でPostGISを使えるようにする。[PostGIS]</a><br />
				lwpostgis.sql ： /usr/share/pgsql/contrib/lwpostgis.sql<br />
				spatial_ref_sys.sql ： /usr/share/pgsql/contrib/spatial_ref_sys.sql
				</li>
				</ul>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/163/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/163" />
	</item>
		<item>
		<title>[Ubuntu]Ubuntu8.10へRailsをインストールしたよ。[Rails]</title>
		<link>http://ore.saizensen.net/archives/148</link>
		<comments>http://ore.saizensen.net/archives/148#comments</comments>
		<pubDate>Fri, 21 Nov 2008 08:18:09 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[Lang]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[インストールメモ]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/?p=148</guid>
		<description><![CDATA[rubyとかrailsとかImagemagickとかごった煮インストール。 % sudo apt-get install ruby ruby-dev irb rubygems libruby-extras libgit- [...]]]></description>
			<content:encoded><![CDATA[				<ol>
				<li>rubyとかrailsとかImagemagickとかごった煮インストール。
				<pre>
% sudo apt-get install ruby ruby-dev irb rubygems libruby-extras libgit-ruby librmagick-ruby vim-ruby vim-rails imagemagick libmagick++9-dev sqlite libsqlite0-dev libsqlite3-dev sqlitebrowser libmysqlclient15-dev  postgresql-server-dev-8.3
% sudo apt-get install lighttpd libfcgi-dev
% sudo gem install rails
% sudo gem install rmagick
% sudo gem install sqlite3-ruby
% sudo gem install mysql
% sudo gem install postgres
% sudo gem install postgres-pr
% sudo gem install vim-ruby
% sudo gem install mongrel
% sudo gem install mongrel_cluster
% sudo gem install fcgi
% sudo gem install net-ssh
% sudo gem install net-sftp
% sudo gem install Selenium
% sudo gem install jpmobile
% sudo gem install ruby-debug
% sudo gem install refe
% sudo gem install xml-simple
</pre>
				</li>
				<li>次に<a href="http://i.loveruby.net/ja/prog/refe.html">Refe</a>をインストールする。
				<ul>
				<li>インストール。
				<pre>
% wget http://i.loveruby.net/archive/refe/refe-0.8.0-withdocsrc.tar.gz
% tar zxvf refe-0.8.0-withdocsrc.tar.gz
% cd refe-0.8.0
% ruby setup.rb config
% ruby setup.rb setup
% sudo ruby setup.rb install
</pre>
				</li>
				<li>環境変数を設定する。
				<pre>
$ vi .zshrc
# Refe
REFE_DATA_DIR=/usr/share/refe
export REFE_DATA_DIR
</pre>
				</li>
				</ul>
				</li>
				</ol>
				<p><strong>※</strong>　% sudo gem install xml-simple をインストールのは、Ubuntu8.10で ruby script/generate　とかすると以下のwarningを吐く為。</p>
				<pre>
/usr/lib/ruby/1.8/xmlsimple.rb:275: warning: already initialized constant KNOWN_OPTIONS
/usr/lib/ruby/1.8/xmlsimple.rb:280: warning: already initialized constant DEF_KEY_ATTRIBUTES
/usr/lib/ruby/1.8/xmlsimple.rb:281: warning: already initialized constant DEF_ROOT_NAME
/usr/lib/ruby/1.8/xmlsimple.rb:282: warning: already initialized constant DEF_CONTENT_KEY
/usr/lib/ruby/1.8/xmlsimple.rb:283: warning: already initialized constant DEF_XML_DECLARATION
/usr/lib/ruby/1.8/xmlsimple.rb:284: warning: already initialized constant DEF_ANONYMOUS_TAG
/usr/lib/ruby/1.8/xmlsimple.rb:285: warning: already initialized constant DEF_FORCE_ARRAY
/usr/lib/ruby/1.8/xmlsimple.rb:286: warning: already initialized constant DEF_INDENTATION
/usr/lib/ruby/1.8/xmlsimple.rb:287: warning: already initialized constant DEF_KEY_TO_SYMBOL
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/148/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/148" />
	</item>
		<item>
		<title>[PHP]CentOSへXCacheをインストールしたメモ。[XCache]</title>
		<link>http://ore.saizensen.net/archives/113</link>
		<comments>http://ore.saizensen.net/archives/113#comments</comments>
		<pubDate>Fri, 07 Nov 2008 06:24:39 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[インストールメモ]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/?p=113</guid>
		<description><![CDATA[またインストールメモ。今後、サーバーを作る時用の自分用メモばっか書いてますな、最近。 ということで、CentOS5.2へXCacheをインストールしました。 phpizeの為に、php-deveをインストール。 # yu [...]]]></description>
			<content:encoded><![CDATA[				<p>またインストールメモ。今後、サーバーを作る時用の自分用メモばっか書いてますな、最近。<br />
				ということで、<strong>CentOS5.2</strong>へ<a href="http://xcache.lighttpd.net/">XCache</a>をインストールしました。</p>
				<ol>
				<li>phpizeの為に、php-deveをインストール。
				<pre># yum -y install php-devel</pre>
</li>
<li><strong>Xcache</strong>の取得 &#038;&#038; インストール。
<pre>
# cd /usr/local/src
# wget http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz
# tar zxvf xcache-1.2.2.tar.gz
# cd xcache-1.2.2
# phpize
# ./configure --enable-xcache --enable-xcache-coverager
# make
# make test
# make install
</pre>
				<p>インストール後、表示されるパスをメモしておく。↓みたいな。</p>
				<pre>
Installing shared extensions: /usr/lib64/php/modules/
</pre>
				</li>
				<li><strong>XCache</strong>のWebインタフェースを公開ディレクトリへコピー。
				<pre>
# cp -R admin /var/www/html/
# cp -R coverager /var/www/html/
# mv /var/www/html/admin /var/www/html/xcache
</pre>
				</li>
				<li><strong>XCache</strong>の設定。
				<pre>
# mkdir /tmp/pcov
# chown apache.apache /tmp/pcov ##←Apache実行ユーザーへ
# cat xcache.ini >> /etc/php.ini
# cat /proc/cpuinfo | grep -c processor ##←表示された数値をメモ。
# echo "< ?php echo md5('pass'); ?>" | php ##←表示された文字列をメモ。
# vi /etc/php.ini
</pre>
				<p>以下、/etc/php.ini の<strong>XCache</strong>設定内容。</p>
				<ul>
				<li>zend_extension = インストール後表示されたパスを指定。</li>
				<li>xcache.count = # cat /proc/cpuinfo | grep -c processor で表示された数値。</li>
				<li>xcache.admin.user = &#8220;hoge&#8221; # 適当なユーザーを指定。</li>
				<li>xcache.admin.pass = # echo &#8220;< ?php echo md5('pass'); ?>&#8221; | php で表示された文字列。</li>
				</ul>
				<pre>
[xcache-common]
;; install as zend extension (recommended), normally "$extension_dir/xcache.so"
;zend_extension = /usr/local/lib/php/extensions/non-debug-non-zts-xxx/xcache.so
zend_extension = /usr/lib64/php/modules/xcache.so
; zend_extension_ts = /usr/local/lib/php/extensions/non-debug-zts-xxx/xcache.so
;; For windows users, replace xcache.so with php_xcache.dll
;zend_extension_ts = c:/php/extensions/php_xcache.dll
;; or install as extension, make sure your extension_dir setting is correct
; extension = xcache.so
;; or win32:
; extension = php_xcache.dll

[xcache.admin]
xcache.admin.enable_auth = On
xcache.admin.user = "hoge"
; xcache.admin.pass = md5($your_password)
xcache.admin.pass = "******************************"

[xcache]
; ini only settings, all the values here is default unless explained

; select low level shm/allocator scheme implemenation
xcache.shm_scheme =        "mmap"
; to disable: xcache.size=0
; to enable : xcache.size=64M etc (any size > 0) and your system mmap allows
xcache.size  =                64M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
xcache.count =                 1
; just a hash hints, you can always store count(items) > slots
xcache.slots =                8K
; ttl of the cache item, 0=forever
xcache.ttl   =                 0
; interval of gc scanning expired items, 0=no scan, other values is in seconds
xcache.gc_interval =           0

; same as aboves but for variable cache
xcache.var_size  =            8M
xcache.var_count =             1
xcache.var_slots =            8K
; default ttl
xcache.var_ttl   =           600
xcache.var_maxttl   =       3600
xcache.var_gc_interval =     300

xcache.test =                Off
; N/A for /dev/zero
xcache.readonly_protection = Off
; for *nix, xcache.mmap_path is a file path, not directory.
; Use something like "/tmp/xcache" if you want to turn on ReadonlyProtection
; 2 group of php won't share the same /tmp/xcache
; for win32, xcache.mmap_path=anonymous map name, not file path
xcache.mmap_path =    "/tmp/xcache"

; leave it blank(disabled) or "/tmp/phpcore/"
; make sure it's writable by php (without checking open_basedir)
xcache.coredump_directory =   ""

; per request settings
xcache.cacher =               On
xcache.stat   =               On
xcache.optimizer =           Off

[xcache.coverager]
; per request settings
; enable coverage data collecting for xcache.coveragedump_directory and xcache_coverager_start/stop/get/clean() functions (will hurt executing performance)
xcache.coverager =          On

; ini only settings
; make sure it's readable (care open_basedir) by coverage viewer script
; requires xcache.coverager=On
xcache.coveragedump_directory = "/tmp/pcov"
</pre>
				</li>
				<li>Apacheを再起動。
				<pre># /etc/rc.d/init.d/httpd restart</pre>
</li>
<li>/var/www/html/coveragerディレクトリへ.htaccessを設置。↓内容。
<pre>
AuthUserFile /etc/httpd/conf/.htpasswd
AuthGroupFile /dev/null
AuthName "XCache Coverage Viewer"
AuthType Basic
#require valid-user
require user hoge
</pre>
				</li>
				</ol>
				<p>以上。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/113/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/113" />
	</item>
		<item>
		<title>[cakephp1.2]CakePHP1.2.0.7296 RC2用DRYなエラーメッセージ出力を一部修正しました。[validate]</title>
		<link>http://ore.saizensen.net/archives/102</link>
		<comments>http://ore.saizensen.net/archives/102#comments</comments>
		<pubDate>Wed, 22 Oct 2008 09:34:49 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[validate]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/?p=102</guid>
		<description><![CDATA[以前のエントリー[cakephp1.2]CakePHP1.2.0.7296 RC2用DRYなエラーメッセージ出力。[validate] で載せていた【app/models/app_model.php】内のinvalidF [...]]]></description>
			<content:encoded><![CDATA[				<p>以前のエントリー<a href="http://ore.saizensen.net/archives/92">[cakephp1.2]CakePHP1.2.0.7296 RC2用DRYなエラーメッセージ出力。[validate]</a><br />
				で載せていた<em>【app/models/app_model.php】</em>内の<em>invalidFields</em>ファンクション内で<br />
				validate設定の<strong>”required”</strong>を考慮したコードになっていなかったので修正しました。</p>
				<p><a href="http://ore.saizensen.net/archives/92">[cakephp1.2]CakePHP1.2.0.7296 RC2用DRYなエラーメッセージ出力。[validate]</a>に修正済のコードを載せておきました。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/102/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/102" />
	</item>
		<item>
		<title>[cakephp1.2]CakePHP1.2でprefixルーティング設定時の注意点。[携帯]</title>
		<link>http://ore.saizensen.net/archives/94</link>
		<comments>http://ore.saizensen.net/archives/94#comments</comments>
		<pubDate>Mon, 20 Oct 2008 10:25:08 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[携帯]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/?p=94</guid>
		<description><![CDATA[CakePHP1.2.0.7296 RC2で携帯ページを作り始めました。 Versionが1.1の時や、1.2.0.6311 betaなどの時はwebservice機能を使って携帯に対応してましたが、 いつのまにか触らな [...]]]></description>
			<content:encoded><![CDATA[				<p><strong>CakePHP1.2.0.7296 RC2</strong>で携帯ページを作り始めました。<br />
				Versionが1.1の時や、1.2.0.6311 betaなどの時はwebservice機能を使って携帯に対応してましたが、<br />
				いつのまにか触らない間にwebservice機能が無くなっていたので、</p>
				<ul>
				<li><a href="http://www.1x1.jp/blog/2008/04/cakephp_12_routing_prefix.html">CakePHP 1.2で携帯用ビューを表示する</a></li>
				<li><a href="http://sand-man.blog.so-net.ne.jp/2008-09-11">CakePHP その20 〜1.2RC2でPC&#038;携帯対応サイトを考えた 〜　[CakePHP]</a></li>
				<li><a href="http://sand-man.blog.so-net.ne.jp/2008-09-20">CakePHP その21 〜MobileHelper2 〜　[CakePHP]</a></li>
				</ul>
				<p>を参考にしました。基本的にはそのままコードを使わせてもらいました。<br />
				あとは、CakePHPガイドブックに載っているMobileComponentや、<a href="http://php-develop.org/MobilePictogramConverter/">MobilePictogramConverter</a>で簡単に作れるEmojiComponentを読み込んだりと、以前に作った物をそのまま流用という感じです。</p>
				<p>で、肝心の注意点ですが、</p>
				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">Router<span style="color: #339933;">::</span><span style="color: #004000;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/m/:controller/:action/*'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'prefix'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'mobile'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>とするだけだと、Viewで</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$paginator</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">prev</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt; &lt; 前へ&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> 
<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$paginator</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">numbers</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> 
<span style="color: #339933;">&lt;</span> ?php <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$paginator</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">next</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;次へ &gt;&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>
				
				<p>と書いていると、携帯用viewは良いんですが、PC用viewでのリンクが<br />
				<strong>http://localhost:8080/~bubbkis/m/staffs/clientsList/page:2</strong><br />
				みたいな感じでPC用の出力画面なのに、URLに<strong>「m」</strong>が入ってしまいました。<br />
				ということで、</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: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/\/m\//&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> Router<span style="color: #339933;">::</span><span style="color: #004000;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/m/:controller/:action/*'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'prefix'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'mobile'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>としましたよ。と。<br />
無駄にRouterクラスまで見に行ったりしてたら半日使っちゃったよ・・・こんだけの事で。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/94/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/94" />
	</item>
		<item>
		<title>[cakephp1.2]CakePHP1.2.0.7296 RC2用DRYなエラーメッセージ出力。[validate]</title>
		<link>http://ore.saizensen.net/archives/92</link>
		<comments>http://ore.saizensen.net/archives/92#comments</comments>
		<pubDate>Mon, 22 Sep 2008 05:51:08 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[validate]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/archives/92</guid>
		<description><![CDATA[※　2008/10/22追記 【app/models/app_model.php】内のinvalidFieldsファンクション内でvalidate設定の&#8221;required&#8221;を考慮したコードになって [...]]]></description>
			<content:encoded><![CDATA[				<p><strong>※　2008/10/22追記</strong><br />
				<em>【app/models/app_model.php】内のinvalidFieldsファンクション内でvalidate設定の&#8221;required&#8221;を考慮したコードになっていなかったので修正しました。適当なコード載っけてすみません。</em></p>
				<p>以前にngtnさんの<a href="http://d.hatena.ne.jp/ngtn/20080323/1206281439">validationのメッセージ出力をDRYにしてみる</a>っていうエントリーを見てから、CakePHP1.2ではずっとDRYなエラーメッセージ出力を使わせてもらってたんですが、CakePHPのバージョンを<strong>1.2.0.7296 RC2</strong>にすると動かなくなってしまいました。</p>
				<p>で、動くようにしてみましたよ。偉そうにいうほどの修正量じゃありませんが・・・<br />
				修正したのは【app/app_model.php】のみです。全部載っけておきます。</p>
				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
config<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'messages'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> AppModel <span style="color: #000000; font-weight: bold;">extends</span> Model <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span> <span style="color: #339933;">=&amp;</span> ConnectionManager<span style="color: #339933;">::</span><span style="color: #004000;">getDataSource</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">useDbConfig</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> escape<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">value</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//テーブル名のゲッタ</span>
	<span style="color: #000000; font-weight: bold;">function</span> getTableName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">//重複チェックのバリデート</span>
	<span style="color: #000000; font-weight: bold;">function</span> checkDuplicate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$cond</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">key</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'= '</span><span style="color: #339933;">.</span><span style="color: #990000;">current</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getID</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$cond</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTableName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'!= '</span><span style="color: #339933;">.</span><span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findCount</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cond</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * invalidFieldsメソッドのオーバーライド
	 *
	 * @param array $data Parameter usage is deprecated, set Model::$data instead
	 * @return array Array of invalid fields
	 * @access public
	 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> invalidFields<span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</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;">Behaviors</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">trigger</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'beforeValidate'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'break'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'breakOn'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">beforeValidate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validationErrors</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validate</span><span style="color: #009900;">&#41;</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;">validate</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validationErrors</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$methods</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_map</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'strtolower'</span><span style="color: #339933;">,</span> <span style="color: #990000;">get_class_methods</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$behaviorMethods</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_keys</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Behaviors</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">methods</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">alias</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">alias</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$Validation</span> <span style="color: #339933;">=&amp;</span> Validation<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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;">validate</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$fieldName</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$ruleSet</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ruleSet</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ruleSet</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ruleSet</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'rule'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$ruleSet</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ruleSet</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$default</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'allowEmpty'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'rule'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'blank'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'last'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'on'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ruleSet</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$index</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$validator</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$validator</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rule'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$validator</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #000088;">$validator</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$default</span><span style="color: #339933;">,</span> <span style="color: #000088;">$validator</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'This field cannot be left blank'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #000088;">$messageParams</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message_params'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$messageParams</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message_params'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'on'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'on'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'create'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__exists<span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'on'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'update'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__exists<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$fieldName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'required'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$fieldName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$fieldName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$fieldName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'allowEmpty'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">false</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;">invalidate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fieldName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$message</span><span style="color: #339933;">,</span> <span style="color: #000088;">$messageParams</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'last'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array_key_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fieldName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$fieldName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$fieldName</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'0'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'allowEmpty'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'rule'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$rule</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'rule'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
							<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'rule'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
							<span style="color: #000088;">$ruleParams</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$fieldName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array_values</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'rule'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
							<span style="color: #000088;">$messageParams</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_values</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'rule'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
						<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$rule</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'rule'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
							<span style="color: #000088;">$ruleParams</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$fieldName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
							<span style="color: #000088;">$messageParams</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">array_key_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rule</span><span style="color: #339933;">,</span> Messages<span style="color: #339933;">::</span><span style="color: #000088;">$error</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> Messages<span style="color: #339933;">::</span><span style="color: #000088;">$error</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$rule</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
							<span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$message</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
&nbsp;
						<span style="color: #000088;">$valid</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;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rule</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$methods</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$ruleParams</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_diff_key</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #339933;">,</span> <span style="color: #000088;">$default</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
							<span style="color: #000088;">$ruleParams</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fieldName</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$ruleParams</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
							<span style="color: #000088;">$valid</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dispatchMethod</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rule</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ruleParams</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rule</span><span style="color: #339933;">,</span> <span style="color: #000088;">$behaviorMethods</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rule</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$behaviorMethods</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$ruleParams</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_diff_key</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #339933;">,</span> <span style="color: #000088;">$default</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
							<span style="color: #000088;">$ruleParams</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fieldName</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$ruleParams</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
							<span style="color: #000088;">$valid</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Behaviors</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dispatchMethod</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #000088;">$rule</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ruleParams</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">method_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$Validation</span><span style="color: #339933;">,</span> <span style="color: #000088;">$rule</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$valid</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$Validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dispatchMethod</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rule</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ruleParams</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'rule'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #000088;">$valid</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rule</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$fieldName</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$valid</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
								<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$index</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
									<span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$index</span><span style="color: #339933;">;</span>
								<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
									<span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> ife<span style="color: #009900;">&#40;</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$index</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ruleSet</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$index</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
								<span style="color: #009900;">&#125;</span>
							<span style="color: #009900;">&#125;</span>
							<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">invalidate</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fieldName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'message'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$messageParams</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
							<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$validator</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'last'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
								<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
							<span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validationErrors</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * invalidateのオーバーライド
	 *
	 * @param string $field The name of the field to invalidate
	 * @param string $value Name of validation rule that was not met
	 * @access public
	 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> invalidate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$messageParams</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validationErrors</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;">validationErrors</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$messageParams</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #990000;">vsprintf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #000088;">$messageParams</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #666666; font-style: italic;">// 既にセットしてある場合は、区切り文字を挟んで連結する</span>
		<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;">validationErrors</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#93;</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;">validationErrors</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.=</span> Messages<span style="color: #339933;">::</span><span style="color: #000088;">$separator</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validationErrors</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>
				
				<p>こんだけです。いちおう他のスクリプトも。<br />
				【app/config/messages.php】</p>
				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000000; font-weight: bold;">class</span> Messages <span style="color: #009900;">&#123;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * メッセージの区切り文字
	 *
	 * @var string
	 */</span>
	static <span style="color: #000088;">$separator</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * validationルールに対応するエラーメッセージ
	 *
	 * @var array
	 */</span>
	static <span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		VALID_NOT_EMPTY	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'必ず入力してください。'</span><span style="color: #339933;">,</span>
		VALID_NUMBER 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'半角数字を入力してください。'</span><span style="color: #339933;">,</span>
		VALID_EMAIL 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'メールアドレス形式で入力してください。'</span><span style="color: #339933;">,</span>
		VALID_YEAR 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'年(1000~2999)を入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'alphaNumeric'</span> 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'半角英数字を入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'between'</span> 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'%1$d文字以上%2$d文字以内の半角数字を入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'blank'</span> 		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'空でなければなりません。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'cc'</span> 		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'クレジットカード番号として正しくありません。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'comparison'</span> 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'入力値%1$s%2$sを満たす値を入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'custom'</span> 		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'入力値が正しくありません。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'date'</span> 		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'日付形式(%1$s)で入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'decimal'</span> 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'小数点第%1$d位までの半角数字を入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'email'</span> 		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'メールアドレス形式で入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'equalTo'</span> 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'入力値が&quot;%1$s&quot;と一致しません。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'extension'</span> 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'拡張子が正しくありません。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'file'</span> 		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>	<span style="color: #666666; font-style: italic;">// 実装されていない</span>
		<span style="color: #0000ff;">'ip'</span> 		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'IPアドレス形式で入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'minLength'</span> 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'%1$d文字以上で入力してください'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'maxLength'</span> 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'%1$d文字以内で入力してください'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'money'</span> 		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'入力値が正しくありません。'</span><span style="color: #339933;">,</span><span style="color: #666666; font-style: italic;">// 通貨?		</span>
		<span style="color: #0000ff;">'multiple'</span> 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>	<span style="color: #666666; font-style: italic;">// 実装されていない</span>
		<span style="color: #0000ff;">'numeric'</span> 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'半角数字を入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'phone'</span> 		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'電話番号形式で入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'postal'</span> 		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'郵便番号形式で入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'range'</span> 		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'%1$dより大きく%2$dより小さい半角数字を入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'ssn'</span> 		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ソーシャルセキュリティナンバー形式で入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'url'</span> 		<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'URL形式で入力してください。'</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">'userDefined'</span> 	<span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'入力値が正しくありません。'</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>
				
				<p>【app/views/helpers/app_form.php】</p>
				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000000; font-weight: bold;">class</span> AppFormHelper <span style="color: #000000; font-weight: bold;">extends</span> FormHelper <span style="color: #009900;">&#123;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * errorメソッドのオーバーライド
	 *
	 * @param string $field A field name, like &quot;Modelname.fieldname&quot;, &quot;Modelname/fieldname&quot; is deprecated
	 * @param string $text		Error message
	 * @param array $options	Rendering options for &lt;div /&gt; wrapper tag
	 * @return string If there are errors this method returns an error message, otherwise null.
	 * @access public
	 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> error<span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</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;">setEntity</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wrap'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'error-message'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'escape'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tagIsInvalid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$error</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$error</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$error</span><span style="color: #339933;">--;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$error</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$error</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$error</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error in field %s'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> Inflector<span style="color: #339933;">::</span><span style="color: #004000;">humanize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">field</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'escape'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> h<span style="color: #009900;">&#40;</span><span style="color: #000088;">$error</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'escape'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000088;">$messages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span>Messages<span style="color: #339933;">::</span><span style="color: #000088;">$separator</span><span style="color: #339933;">,</span> <span style="color: #000088;">$error</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$messages</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wrap'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wrap'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">tags</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'error'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_parseAttributes<span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wrap'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$output</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$message</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$output</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>	
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>
				
				<p>【app/controllers/app_controller.php】</p>
				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>php <span style="color: #000000; font-weight: bold;">class</span> AppController <span style="color: #000000; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$helpers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Html'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Form'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'AppForm'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;/</span>php<span style="color: #339933;">&gt;</span></pre></div></div>
				
				<p>以上です。使いかたはngtnさんの<a href="http://d.hatena.ne.jp/ngtn/20080323/1206281439">validationのメッセージ出力をDRYにしてみる</a>っていうエントリーを見てください。<span id="more-92"></span></p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/92/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/92" />
	</item>
		<item>
		<title>[cakephp]テーブル未使用モデルで$this-&gt;Model-&gt;create()するとエラー吐くよ。</title>
		<link>http://ore.saizensen.net/archives/74</link>
		<comments>http://ore.saizensen.net/archives/74#comments</comments>
		<pubDate>Tue, 13 May 2008 10:00:20 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[validate]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/archives/74</guid>
		<description><![CDATA[Modelで var $useTable = false; という設定をして、 $this-&#62;Model-&#62;create&#40;$this-&#62;data&#41;; をすると、 Warning &#40 [...]]]></description>
			<content:encoded><![CDATA[				<p>Modelで</p>
				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$useTable</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span></pre></div></div>

<p>という設定をして、</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;">Model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</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: #339933;">;</span></pre></div></div>
				
				<p>をすると、</p>
				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">Warning <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">512</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>Model<span style="color: #339933;">::</span><span style="color: #004000;">getColumnType</span><span style="color: #009900;">&#41;</span> Unable to locate model field data<span style="color: #339933;">.</span> <span style="color: #b1b100;">If</span> you are using a model without a database table<span style="color: #339933;">,</span> try implementing schema<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#91;</span>CORE<span style="color: #339933;">/</span>cake<span style="color: #339933;">/</span>libs<span style="color: #339933;">/</span>model<span style="color: #339933;">/</span>model<span style="color: #339933;">.</span>php<span style="color: #339933;">,</span> line <span style="color: #cc66cc;">959</span><span style="color: #009900;">&#93;</span>
Code <span style="color: #339933;">|</span> Context
&nbsp;
<span style="color: #000088;">$column</span>	<span style="color: #339933;">=</span>	<span style="color: #0000ff;">&quot;how_know&quot;</span>
<span style="color: #000088;">$cols</span>	<span style="color: #339933;">=</span>	<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #000088;">$cols</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">schema</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cols</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">trigger_error</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'(Model::getColumnType) Unable to locate model field data. If you are using a model without a database table, try implementing schema()'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">E_USER_WARNING</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Model<span style="color: #339933;">::</span><span style="color: #004000;">getColumnType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> CORE<span style="color: #339933;">/</span>cake<span style="color: #339933;">/</span>libs<span style="color: #339933;">/</span>model<span style="color: #339933;">/</span>model<span style="color: #339933;">.</span>php<span style="color: #339933;">,</span> line <span style="color: #cc66cc;">959</span>
Model<span style="color: #339933;">::</span><span style="color: #004000;">deconstruct</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> CORE<span style="color: #339933;">/</span>cake<span style="color: #339933;">/</span>libs<span style="color: #339933;">/</span>model<span style="color: #339933;">/</span>model<span style="color: #339933;">.</span>php<span style="color: #339933;">,</span> line <span style="color: #cc66cc;">857</span>
Model<span style="color: #339933;">::</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> CORE<span style="color: #339933;">/</span>cake<span style="color: #339933;">/</span>libs<span style="color: #339933;">/</span>model<span style="color: #339933;">/</span>model<span style="color: #339933;">.</span>php<span style="color: #339933;">,</span> line <span style="color: #cc66cc;">839</span>
Model<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> CORE<span style="color: #339933;">/</span>cake<span style="color: #339933;">/</span>libs<span style="color: #339933;">/</span>model<span style="color: #339933;">/</span>model<span style="color: #339933;">.</span>php<span style="color: #339933;">,</span> line <span style="color: #cc66cc;">1014</span>
PartnersController<span style="color: #339933;">::</span><span style="color: #004000;">regist</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> APP<span style="color: #339933;">/</span>controllers<span style="color: #339933;">/</span>partners_controller<span style="color: #339933;">.</span>php<span style="color: #339933;">,</span> line <span style="color: #cc66cc;">20</span>
Dispatcher<span style="color: #339933;">::</span>_invoke<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> CORE<span style="color: #339933;">/</span>cake<span style="color: #339933;">/</span>dispatcher<span style="color: #339933;">.</span>php<span style="color: #339933;">,</span> line <span style="color: #cc66cc;">265</span>
Dispatcher<span style="color: #339933;">::</span><span style="color: #004000;">dispatch</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> CORE<span style="color: #339933;">/</span>cake<span style="color: #339933;">/</span>dispatcher<span style="color: #339933;">.</span>php<span style="color: #339933;">,</span> line <span style="color: #cc66cc;">237</span>
<span style="color: #009900;">&#91;</span>main<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> APP<span style="color: #339933;">/</span>webroot<span style="color: #339933;">/</span>index<span style="color: #339933;">.</span>php<span style="color: #339933;">,</span> line <span style="color: #cc66cc;">84</span></pre></div></div>
				
				<p>というエラーを吐いてきたんですよ。<br />
				エラー見ると、</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;">data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;Model&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;how_know&quot;</span><span style="color: #009900;">&#93;</span></pre></div></div>

<p>という要素に格納されている値に問題あるみたいですね。<br />
ちなみに、セレクトボックスと選択したした値（配列）が格納されています。</p>
<p>で、色々と調べてみると、Tableを使ってはいなくても、TableのSchema情報を定義しておけ、と。<br />
つーことでModelを再設定します。</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$useTable</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$_schema</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;how_know&quot;</span><span style="color: #339933;">=&gt;</span>array<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;type&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;string&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>
				
				<p>これでエラーを吐かなくなりました。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/74/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/74" />
	</item>
		<item>
		<title>[cakephp1.2]validate使用時の注意。[validate]</title>
		<link>http://ore.saizensen.net/archives/70</link>
		<comments>http://ore.saizensen.net/archives/70#comments</comments>
		<pubDate>Mon, 21 Apr 2008 09:42:10 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[validate]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/archives/70</guid>
		<description><![CDATA[cakephp1.1の時のように、 $this-&#62;yourmodel-&#62;validates&#40;$this-&#62;data&#41;; とすると、cakephp1.2では (Model::validat [...]]]></description>
			<content:encoded><![CDATA[				<p>cakephp1.1の時のように、</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;">yourmodel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validates</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: #339933;">;</span></pre></div></div>

<p>とすると、cakephp1.2では</p>
<pre>
(Model::validates) Parameter usage is deprecated, set the $data property instead
Warning (512): [CORE/cake/libs/model/model.php, line 1647]
</pre>
				<p>とWarningを吐きます。1.2では下記のようにしましょう。</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: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">YourModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</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: #339933;">&amp;&amp;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">YourModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validates</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// validation ok</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// validation not ok</span>
<span style="color: #009900;">&#125;</span></pre></div></div>
				
				<p>また、新規登録時のvalidateルールを下記の様に設定するとする。</p>
				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$validate</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #339933;">=&gt;</span>array<span style="color: #009900;">&#40;</span>
					<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;rule&quot;</span><span style="color: #339933;">=&gt;</span>VALID_NOT_EMPTY<span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">&quot;kana&quot;</span><span style="color: #339933;">=&gt;</span>array<span style="color: #009900;">&#40;</span>
					<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;rule&quot;</span><span style="color: #339933;">=&gt;</span>VALID_NOT_EMPTY<span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#41;</span></pre></div></div>
				
				<p>でも、データ更新時にはvaidateルールから<br />
				「kana」のvalidateルールを除きたい場合は、</p>
				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">YourModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validate</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'kana'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>と書くよ。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/70/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/70" />
	</item>
		<item>
		<title>[cakephp]FormHelperから自動出力されるdiv要素を消す方法。</title>
		<link>http://ore.saizensen.net/archives/68</link>
		<comments>http://ore.saizensen.net/archives/68#comments</comments>
		<pubDate>Tue, 15 Apr 2008 09:28:51 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/archives/68</guid>
		<description><![CDATA[div要素を外したい場合には $form-&#62;submit&#40;'登録', array&#40;'div'=&#62;false&#41;&#41;; $form-&#62;input&#40;&#34;User/ [...]]]></description>
			<content:encoded><![CDATA[				<p>div要素を外したい場合には</p>
				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'登録'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'div'</span><span style="color: #339933;">=&gt;</span>false<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;User/name&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;type&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;text&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;label&quot;</span><span style="color: #339933;">=&gt;</span>false<span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;div&quot;</span><span style="color: #339933;">=&gt;</span>false<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>
				
				<p>こんな感じ。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/68/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/68" />
	</item>
		<item>
		<title>[Postfix]メール受信時にスクリプトを走らせる方法。</title>
		<link>http://ore.saizensen.net/archives/60</link>
		<comments>http://ore.saizensen.net/archives/60#comments</comments>
		<pubDate>Tue, 11 Mar 2008 11:31:24 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[Lang]]></category>
		<category><![CDATA[Postfix]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[メール受信起動スクリプト]]></category>
		<category><![CDATA[絶対忘れる。]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/archives/60</guid>
		<description><![CDATA[# vi /etc/aliases hoge: hogehoge "&#124; /usr/bin/php -q /var/www/hoge.php" # newaliases とする。 hogeでメール受信したら、hogehog [...]]]></description>
			<content:encoded><![CDATA[				<pre>
# vi /etc/aliases
hoge:     hogehoge "| /usr/bin/php -q /var/www/hoge.php"

# newaliases</pre>
				<p>とする。<br />
				hogeでメール受信したら、hogehogeへメール転送する設定にしないとhogeに来たメールは一生日の目を見ることはないでしょう。<br />
				まぁメールがスクリプト起動のキー以外に必要無い場合は、hogehogeの箇所は必要無し。</p>
				<p>この手は写メール投稿でよく使うけど、注意点はメール受信からスクリプト起動すると、<br />
				postfixユーザかnobodyユーザで動くからパーミッションに注意。<br />
				起動スクリプトからincludeするライブラリなり、<br />
				写メールに付いている写真を保存するディレクトリなり。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/60/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/60" />
	</item>
		<item>
		<title>CakePHPでCronを使う。</title>
		<link>http://ore.saizensen.net/archives/51</link>
		<comments>http://ore.saizensen.net/archives/51#comments</comments>
		<pubDate>Tue, 19 Feb 2008 07:37:40 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cron]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/archives/51</guid>
		<description><![CDATA[&#60;?php $_GET&#91;'url'&#93; = &#34;crons/vacuum/&#34;; require_once&#40; dirname&#40; dirname&#40;__FILE__ [...]]]></description>
			<content:encoded><![CDATA[				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;crons/vacuum/&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/index.php&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>
				
				<p>Cronで動かすスクリプトに上記の様にコードを書く。<br />
				すると、</p>
				<p>http://hogehoge.com/crons/vacuum</p>
				<p>と同じ動作をする。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/51/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/51" />
	</item>
		<item>
		<title>エロガキ涙の一行スクリプト</title>
		<link>http://ore.saizensen.net/archives/43</link>
		<comments>http://ore.saizensen.net/archives/43#comments</comments>
		<pubDate>Sun, 10 Feb 2008 23:35:18 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[いたずら]]></category>
		<category><![CDATA[エロガキ]]></category>
		<category><![CDATA[プギャーー]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/archives/43</guid>
		<description><![CDATA[エロ小僧(PC初心者)を懲らしめる1行プログラム メモ帳に↓をコピペして for(;;){ WScript.Echo('このウィンドウは永久に消えません。m9（＾Д＾）プギャー'); } ファイル名14才メグ中だし濃厚S [...]]]></description>
			<content:encoded><![CDATA[				<p>エロ小僧(PC初心者)を懲らしめる1行プログラム<br />
				メモ帳に↓をコピペして</p>
				
				<div class="wp_syntax"><div class="code"><pre class="js" style="font-family:monospace;">for(;;){ WScript.Echo('このウィンドウは永久に消えません。m9（＾Д＾）プギャー'); }</pre></div></div>

<p>ファイル名14才メグ中だし濃厚SEX.avi 　 　 　 　 　 　 　 　 　 　 　 　 .jsで保存</p>
<p>これだけでOK<br />
学校等のパソコンに置いておくと面白いかも</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
注意<br />
WSHなのでwindows環境下でないと動作しないです。<br />
自分が涙した方はタスクマネージャから終了できます。<br />
悪用というのも大袈裟だとは思いますが一応厳禁で。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/43/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/43" />
	</item>
		<item>
		<title>CakePHPでファイルのダウンロードのやり方。</title>
		<link>http://ore.saizensen.net/archives/34</link>
		<comments>http://ore.saizensen.net/archives/34#comments</comments>
		<pubDate>Mon, 04 Feb 2008 08:32:24 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[ダウンロード]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/archives/34</guid>
		<description><![CDATA[例えば、 $output_file = sprintf&#40;DB_NAME.&#34;_%s.db&#34;, date&#40;&#34;Ymd-hi&#34;&#41;&#41;; system&#40; [...]]]></description>
			<content:encoded><![CDATA[				<p>例えば、</p>
				
				<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$output_file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>DB_NAME<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;_<span style="color: #009933; font-weight: bold;">%s</span>.db&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Ymd-hi&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">system</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/usr/bin/pg_dump -u &quot;</span><span style="color: #339933;">.</span>DB_NAME<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &lt; &quot;</span><span style="color: #339933;">.</span>AUTH_USER_FILE_PATH<span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &gt; &quot;</span><span style="color: #339933;">.</span>DB_EXPORT_PATH<span style="color: #339933;">.</span><span style="color: #000088;">$output_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">autoRender</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
Configure<span style="color: #339933;">::</span><span style="color: #004000;">write</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'debug'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-disposition: attachment; filename=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$output_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: application/octet-stream; name=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$output_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span>DB_EXPORT_PATH<span style="color: #339933;">.</span><span style="color: #000088;">$output_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span></pre></div></div>
				
				<p>みたいな。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/34/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/34" />
	</item>
		<item>
		<title>rubygems &#8211; mysqlアダプタがインストール出来ない</title>
		<link>http://ore.saizensen.net/archives/20</link>
		<comments>http://ore.saizensen.net/archives/20#comments</comments>
		<pubDate>Tue, 29 Jan 2008 14:40:46 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[Lang]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rubygems]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/archives/20</guid>
		<description><![CDATA[mac OSX 10.4 にgemでmysql2.7のネイティブアダプタがインストール出来ない場合。 sudo gem install mysql &#8212; &#8211;with-mysql-dir=/usr/l [...]]]></description>
			<content:encoded><![CDATA[				<p>mac OSX 10.4 にgemでmysql2.7のネイティブアダプタがインストール出来ない場合。</p>
				<p>sudo gem install mysql &#8212; &#8211;with-mysql-dir=/usr/local/mysql</p>
				<p>Select which gem to install for your platform (i686-darwin8.11.1)<br />
				1. mysql 2.7.3 (mswin32)<br />
				2. mysql 2.7.1 (mswin32)<br />
				3. mysql 2.7 (ruby)<br />
				4. mysql 2.6 (ruby)<br />
				5. Skip this gem<br />
				6. Cancel installation<br />
				&gt; Building native extensions.  This could take a while&#8230;<br />
				ERROR:  While executing gem &#8230; (Gem::Installer::ExtensionBuildError)<br />
				ERROR: Failed to build gem native extension.</p>
				<p>ruby extconf.rb install mysql &#8212; &#8211;with-mysql-dir=/usr/local/mysql<br />
				checking for mysql_query() in -lmysqlclient&#8230; yes<br />
				checking for mysql_ssl_set()&#8230; yes<br />
				checking for mysql.h&#8230; yes<br />
				creating Makefile</p>
				<p>make<br />
				gcc -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8.11.1 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -I/usr/local/mysql/include -I/opt/local/include -fno-common -O2 -fno-common -pipe -fno-common -c mysql.c<br />
				mysql.c: In function ‘query’:<br />
				mysql.c:635: error: invalid storage class for function ‘res_free’<br />
				mysql.c:637: error: ‘res_free’ undeclared (first use in this function)<br />
				mysql.c:637: error: (Each undeclared identifier is reported only once<br />
				mysql.c:637: error: for each function it appears in.)<br />
				mysql.c: In function ‘Init_mysql’:<br />
				mysql.c:1299: error: ‘ulong’ undeclared (first use in this function)<br />
				mysql.c:1299: error: parse error before numeric constant<br />
				mysql.c:1302: error: parse error before numeric constant<br />
				make: *** [mysql.o] Error 1</p>
				<p>Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.<br />
				Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out</p>
				<p>と、エラーを吐く。<br />
				以下、解決法↓</p>
				<p>sudo vim /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/mysql.c.in.<br />
				ファイル先頭に<br />
				#define ulong unsigned long<br />
				と記述。</p>
				<p>cd /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7<br />
				sudo ruby extconf.rb &#8211;with-mysql-config=/usr/local/mysql/bin/mysql_config<br />
				sudo make<br />
				sudo make install</p>
				<p>以上。メモ。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/20/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/20" />
	</item>
		<item>
		<title>JSDeferred（非同期処理）</title>
		<link>http://ore.saizensen.net/archives/18</link>
		<comments>http://ore.saizensen.net/archives/18#comments</comments>
		<pubDate>Tue, 29 Jan 2008 14:33:21 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[非同期処理]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/archives/18</guid>
		<description><![CDATA[ライブラリ「JSDeferred」 非同期処理でもエラーハンドリングしたい。 非同期処理の値の受け渡しをキレイにしたい。 ってときとか。 parallel &#40;&#91; loop&#40;100, functio [...]]]></description>
			<content:encoded><![CDATA[				<p>ライブラリ「<a href="http://coderepos.org/share/wiki/JSDeferre">JSDeferred</a>」<br />
				非同期処理でもエラーハンドリングしたい。<br />
				非同期処理の値の受け渡しをキレイにしたい。<br />
				ってときとか。</p>
				
				<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">parallel <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>
loop<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #009966; font-style: italic;">/* 処理１ */</span>
<span style="color: #000066; font-weight: bold;">return</span> wait<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
loop<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #009966; font-style: italic;">/* 処理２ */</span>
<span style="color: #000066; font-weight: bold;">return</span> wait<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>.
<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #009966; font-style: italic;">/*処理３*/</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>
				
				<p>ってやるとマルチスレッドぽく処理できる。</p>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/18/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/18" />
	</item>
		<item>
		<title>CakePHP の findAll の条件に IN 演算子を使うには</title>
		<link>http://ore.saizensen.net/archives/14</link>
		<comments>http://ore.saizensen.net/archives/14#comments</comments>
		<pubDate>Mon, 28 Jan 2008 05:06:13 +0000</pubDate>
		<dc:creator>bubbkis</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Lang]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[findAll]]></category>
		<category><![CDATA[IN演算子]]></category>

		<guid isPermaLink="false">http://ore.saizensen.net/archives/14</guid>
		<description><![CDATA[CakePHP の findAll の条件に IN 演算子を使うには $this-&#62;model-&#62;findAll&#40;array&#40;'field IN (1,2,3)'&#41;&#41;; または [...]]]></description>
			<content:encoded><![CDATA[				<p>CakePHP の findAll の条件に IN 演算子を使うには</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;">model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findAll</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'field IN (1,2,3)'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>または、</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">findAll</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'field'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://ore.saizensen.net/archives/14/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ore.saizensen.net/archives/14" />
	</item>
	</channel>
</rss>

