<?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>Director&#039;s Cut - art project team Blog - &#187; フレームワーク</title>
	<atom:link href="http://blog.art-p.com/category/%e3%83%95%e3%83%ac%e3%83%bc%e3%83%a0%e3%83%af%e3%83%bc%e3%82%af/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.art-p.com</link>
	<description>ウェブディレクターの技術的な備忘録</description>
	<lastBuildDate>Fri, 16 Dec 2011 10:40:42 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.art-p.com/category/%e3%83%95%e3%83%ac%e3%83%bc%e3%83%a0%e3%83%af%e3%83%bc%e3%82%af/feed/" />
		<item>
		<title>フェスティバ!!のスマートフォン対応しました</title>
		<link>http://blog.art-p.com/%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3/%e3%83%95%e3%82%a7%e3%82%b9%e3%83%86%e3%82%a3%e3%83%90%e3%81%ae%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%97%e3%81%be%e3%81%97%e3%81%9f/</link>
		<comments>http://blog.art-p.com/%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3/%e3%83%95%e3%82%a7%e3%82%b9%e3%83%86%e3%82%a3%e3%83%90%e3%81%ae%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%97%e3%81%be%e3%81%97%e3%81%9f/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 14:34:47 +0000</pubDate>
		<dc:creator>art project team</dc:creator>
				<category><![CDATA[CM]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[デザイン]]></category>
		<category><![CDATA[フェスティバ!!]]></category>
		<category><![CDATA[フレームワーク]]></category>
		<category><![CDATA[プログラム]]></category>
		<category><![CDATA[独自サービス]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[ZendFramework]]></category>
		<category><![CDATA[フェスティバ]]></category>

		<guid isPermaLink="false">http://blog.art-p.com/?p=692</guid>
		<description><![CDATA[現在運営している「フェスティバ!!」のスマートフォン版をリリースしました。 まだ、一部しか対応してませんが、順次対応していく予定です。 スマホ版の最大の特徴は、現在地からイベント開催地までのルートを表示することが出来ます [...]]]></description>
			<content:encoded><![CDATA[<p>現在運営している「フェスティバ!!」のスマートフォン版をリリースしました。<br />
まだ、一部しか対応してませんが、順次対応していく予定です。</p>
<p>スマホ版の最大の特徴は、現在地からイベント開催地までのルートを表示することが出来ます。<br />
是非、利用してみてください!!</p>
<p>URL：<a title="フェスティバ!! スマートフォン版" href="http://sp.festiva.biz/" target="_blank">http://sp.festiva.biz/</a></p>
<p style="text-align: center;"><img src="http://blog.art-p.com/wp-content/uploads/2011/07/top_sp.png" alt="フェスティバ!! スマートフォン版リリース" title="top_sp" width="657" height="300" class="size-full wp-image-693 aligncenter" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.art-p.com/%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3/%e3%83%95%e3%82%a7%e3%82%b9%e3%83%86%e3%82%a3%e3%83%90%e3%81%ae%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%97%e3%81%be%e3%81%97%e3%81%9f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.art-p.com/%e3%83%87%e3%82%b6%e3%82%a4%e3%83%b3/%e3%83%95%e3%82%a7%e3%82%b9%e3%83%86%e3%82%a3%e3%83%90%e3%81%ae%e3%82%b9%e3%83%9e%e3%83%bc%e3%83%88%e3%83%95%e3%82%a9%e3%83%b3%e5%af%be%e5%bf%9c%e3%81%97%e3%81%be%e3%81%97%e3%81%9f/" />
	</item>
		<item>
		<title>[ZendFramework]URLを実際のものとは違うカタチで表示する方法</title>
		<link>http://blog.art-p.com/php/zendframeworkurl%e3%82%92%e5%ae%9f%e9%9a%9b%e3%81%ae%e3%82%82%e3%81%ae%e3%81%a8%e3%81%af%e9%81%95%e3%81%86%e3%82%ab%e3%82%bf%e3%83%81%e3%81%a7%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/</link>
		<comments>http://blog.art-p.com/php/zendframeworkurl%e3%82%92%e5%ae%9f%e9%9a%9b%e3%81%ae%e3%82%82%e3%81%ae%e3%81%a8%e3%81%af%e9%81%95%e3%81%86%e3%82%ab%e3%82%bf%e3%83%81%e3%81%a7%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/#comments</comments>
		<pubDate>Wed, 06 Jul 2011 11:21:29 +0000</pubDate>
		<dc:creator>art project team</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[フェスティバ!!]]></category>
		<category><![CDATA[フレームワーク]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[ZendFramework]]></category>
		<category><![CDATA[フェスティバ]]></category>

		<guid isPermaLink="false">http://blog.art-p.com/?p=688</guid>
		<description><![CDATA[フェスティバ!!でも使ってますが、本来はhttp://hogehoge.jp/user?id=1のようなアドレスをtwitterなどのようにhttp://hogehoge.jp/!/usernameというようなアドレスで [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.festiva.biz/" target="_blank">フェスティバ!!</a>でも使ってますが、本来はhttp://hogehoge.jp/user?id=1のようなアドレスをtwitterなどのようにhttp://hogehoge.jp/!/usernameというようなアドレスで表示させる方法。</p>
<p>※ZenfFrameworkでの方法<br />
<span id="more-688"></span><br />
まず、public/index.phpに独自ルートの構築をします。</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//独自ルート用のコンポーネント呼び出し</span><br />
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Controller/front.php'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Controller/Router/Route.php'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//独自ルートの構築</span><br />
<span style="color: #000088;">$front</span> <span style="color: #339933;">=</span> Zend_Controller_Front<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><br />
<span style="color: #000088;">$router</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$front</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRouter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$route</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Controller_Router_Route<span style="color: #009900;">&#40;</span><br />
&nbsp; <span style="color: #0000ff;">'!/:username'</span><span style="color: #339933;">,</span><br />
&nbsp; <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'controller'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'action'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'index'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'username'</span><span style="color: #339933;">=&gt;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">//独自ルートをルータに定義</span><br />
<span style="color: #000088;">$router</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addRoute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$route</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>手順としては、独自ルートのコンポーネントを呼び出し、<br />
どこのコントローラーとどこのアクションをどんなアドレスに変更するかを設定し、<br />
実際に反映できるように定義すればOK</p>
<p> &#8216;username&#8217;=>null　はデフォルトの値を設定する場合に記述。<br />
デフォルトがない場合はnullにしておく。</p>
<p>上記の場合、userというコントロールのindexアクションのルートを変更しています。<br />
その際のパラメータ名は[username]と設定しています。<br />
http://hogehoge.jp/user?id=1 というアドレスを http://hogehoge.jp/!/abcd というURLで表示できます。<br />
※abcdがusernameパラメータです。</p>
<p>URLルートを変更する場合 http://hogehoge.jp/xxxxx というのは避け、<br />
http://hogehoge.jp/abc/xxxx のように必ず擬似ディレクトリを置くようにしてください。<br />
その際に、絶対に他のコンテンツと同じものにはしないでください。</p>
<p>値を取得する際は下記で取得できます。<br />
上記を例に本来のコントローラー(UserController.php)のindexActionで値を取得</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> indexAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000088;">$hogehoge</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">username</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>余談ですが、「!」は使えましたがtwitterのように「#」は使えませんでした。<br />
制限があるのだろうか？？</p>
<p>ちなみに、<a href="http://www.festiva.biz/" target="_blank">フェスティバ!!</a>の場合は<a href="http://www.festiva.biz/!/artprojectteam" target="_blank">http://www.festiva.biz/!/artprojectteam</a>というように使っています。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.art-p.com/php/zendframeworkurl%e3%82%92%e5%ae%9f%e9%9a%9b%e3%81%ae%e3%82%82%e3%81%ae%e3%81%a8%e3%81%af%e9%81%95%e3%81%86%e3%82%ab%e3%82%bf%e3%83%81%e3%81%a7%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.art-p.com/php/zendframeworkurl%e3%82%92%e5%ae%9f%e9%9a%9b%e3%81%ae%e3%82%82%e3%81%ae%e3%81%a8%e3%81%af%e9%81%95%e3%81%86%e3%82%ab%e3%82%bf%e3%83%81%e3%81%a7%e8%a1%a8%e7%a4%ba%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95/" />
	</item>
		<item>
		<title>ZendFrameworkで意図的にエラー処理をしたいとき</title>
		<link>http://blog.art-p.com/php/zendframework%e3%81%a7%e6%84%8f%e5%9b%b3%e7%9a%84%e3%81%ab%e3%82%a8%e3%83%a9%e3%83%bc%e5%87%a6%e7%90%86%e3%82%92%e3%81%97%e3%81%9f%e3%81%84%e3%81%a8%e3%81%8d/</link>
		<comments>http://blog.art-p.com/php/zendframework%e3%81%a7%e6%84%8f%e5%9b%b3%e7%9a%84%e3%81%ab%e3%82%a8%e3%83%a9%e3%83%bc%e5%87%a6%e7%90%86%e3%82%92%e3%81%97%e3%81%9f%e3%81%84%e3%81%a8%e3%81%8d/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 04:00:13 +0000</pubDate>
		<dc:creator>art project team</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[フレームワーク]]></category>
		<category><![CDATA[ZendFramework]]></category>

		<guid isPermaLink="false">http://blog.art-p.com/?p=612</guid>
		<description><![CDATA[ZendFrameworkを使用して、アクションが見つからないとかコントローラが見つからないだと500エラーを吐き出しますが、DBを使用してデータを生成する場合、アクションもコントローラもあるけどこのページはエラーにした [...]]]></description>
			<content:encoded><![CDATA[<p>ZendFrameworkを使用して、アクションが見つからないとかコントローラが見つからないだと500エラーを吐き出しますが、DBを使用してデータを生成する場合、アクションもコントローラもあるけどこのページはエラーにしたい(例えばログインしてないと見れないとか)場合の処理方法。</p>
<p><span id="more-612"></span>結構、ググりました。<br />
結論！<br />
難しい…。</p>
<p>なので、考えました。<br />
割と簡単な方法がありました。いろいろ新しくクラスを作ってオーバーライドしたりしなくてもすむ方法が！！</p>
<p>コントローラで下記のように書きます。</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//ログイン情報が空の場合</span><br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$login</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Exeption<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ページが見つかりませんでした'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">404</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>といった処理を書きます。<br />
通常のthrow処理はthrow new Zend_Exeption(&#8216;ページが見つかりませんでした&#8217;);と書きますが、この後にオプションでいろいろ付け足すことが出来ます。<br />
今回の404部分はコードが入るようになっています。</p>
<p>そして、エラーアクションで値を取得します。</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> ErrorController <span style="color: #000000; font-weight: bold;">extends</span> Zend_Controller_Action<br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> errorAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp;<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000088;">$errors</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_getParam<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'error_handler'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #000088;">$code</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$errors</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">exception</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp;<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>これで、渡した404の値が取れます。<br />
なぜとれるのかは$errorsをvar_dumpしてみればわかります。<br />
メッセージ以外にもいろいろ渡せるということがわかります。</p>
<p>そして、次にエラー処理を行います。</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$errors</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">case</span> Zend_Controller_Plugin_ErrorHandler<span style="color: #339933;">::</span><span style="color: #004000;">EXCEPTION_NO_ROUTE</span><span style="color: #339933;">:</span><br />
<span style="color: #b1b100;">case</span> Zend_Controller_Plugin_ErrorHandler<span style="color: #339933;">::</span><span style="color: #004000;">EXCEPTION_NO_CONTROLLER</span><span style="color: #339933;">:</span><br />
<span style="color: #b1b100;">case</span> Zend_Controller_Plugin_ErrorHandler<span style="color: #339933;">::</span><span style="color: #004000;">EXCEPTION_NO_ACTION</span><span style="color: #339933;">:</span><br />
<span style="color: #b1b100;">default</span><span style="color: #339933;">:</span><br />
&nbsp;<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$code</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">404</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setHttpResponseCode</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">404</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">//404のエラー処理</span><br />
&nbsp;<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">//アプリケーションエラーの処理など</span><br />
&nbsp;<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>上記のようになります。<br />
なぜ、default内で処理するかというと、いくらコードを渡しても$errors-&gt;typeは「その他」となっているため、デフォルト内で処理をするようになります。</p>
<p>新しく関数を作成するのが面倒な人はこんなやり方でもいいのではないでしょうか？</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.art-p.com/php/zendframework%e3%81%a7%e6%84%8f%e5%9b%b3%e7%9a%84%e3%81%ab%e3%82%a8%e3%83%a9%e3%83%bc%e5%87%a6%e7%90%86%e3%82%92%e3%81%97%e3%81%9f%e3%81%84%e3%81%a8%e3%81%8d/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.art-p.com/php/zendframework%e3%81%a7%e6%84%8f%e5%9b%b3%e7%9a%84%e3%81%ab%e3%82%a8%e3%83%a9%e3%83%bc%e5%87%a6%e7%90%86%e3%82%92%e3%81%97%e3%81%9f%e3%81%84%e3%81%a8%e3%81%8d/" />
	</item>
		<item>
		<title>Doctrineでデータ取得する際に文字化けを直す方法。</title>
		<link>http://blog.art-p.com/%e3%83%a1%e3%83%a2/doctrine%e3%81%a7%e3%83%87%e3%83%bc%e3%82%bf%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b%e9%9a%9b%e3%81%ab%e6%96%87%e5%ad%97%e5%8c%96%e3%81%91%e3%82%92%e7%9b%b4%e3%81%99%e6%96%b9%e6%b3%95%e3%80%82/</link>
		<comments>http://blog.art-p.com/%e3%83%a1%e3%83%a2/doctrine%e3%81%a7%e3%83%87%e3%83%bc%e3%82%bf%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b%e9%9a%9b%e3%81%ab%e6%96%87%e5%ad%97%e5%8c%96%e3%81%91%e3%82%92%e7%9b%b4%e3%81%99%e6%96%b9%e6%b3%95%e3%80%82/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 06:27:14 +0000</pubDate>
		<dc:creator>art project team</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[フレームワーク]]></category>
		<category><![CDATA[メモ]]></category>
		<category><![CDATA[ZendFramework]]></category>

		<guid isPermaLink="false">http://blog.art-p.com/?p=563</guid>
		<description><![CDATA[自分用のメモ Doctrineを使用してDBに接続して、SQLを発行したときに文字化けするので、文字化けを解消する方法。 1$db = Doctrine_Maneger::connection&#40;&#34;mys [...]]]></description>
			<content:encoded><![CDATA[<p>自分用のメモ<br />
Doctrineを使用してDBに接続して、SQLを発行したときに文字化けするので、文字化けを解消する方法。<br />
<span id="more-563"></span></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> Doctrine_Maneger<span style="color: #339933;">::</span><span style="color: #004000;">connection</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mysql://username:password@host/datamesename&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCharset</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;utf8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>上記でUTF8でデータを取得することが可能。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.art-p.com/%e3%83%a1%e3%83%a2/doctrine%e3%81%a7%e3%83%87%e3%83%bc%e3%82%bf%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b%e9%9a%9b%e3%81%ab%e6%96%87%e5%ad%97%e5%8c%96%e3%81%91%e3%82%92%e7%9b%b4%e3%81%99%e6%96%b9%e6%b3%95%e3%80%82/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.art-p.com/%e3%83%a1%e3%83%a2/doctrine%e3%81%a7%e3%83%87%e3%83%bc%e3%82%bf%e5%8f%96%e5%be%97%e3%81%99%e3%82%8b%e9%9a%9b%e3%81%ab%e6%96%87%e5%ad%97%e5%8c%96%e3%81%91%e3%82%92%e7%9b%b4%e3%81%99%e6%96%b9%e6%b3%95%e3%80%82/" />
	</item>
		<item>
		<title>ZendFrameworkでDB接続メモ</title>
		<link>http://blog.art-p.com/%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0/zendframework%e3%81%a7db%e6%8e%a5%e7%b6%9a%e3%83%a1%e3%83%a2/</link>
		<comments>http://blog.art-p.com/%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0/zendframework%e3%81%a7db%e6%8e%a5%e7%b6%9a%e3%83%a1%e3%83%a2/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 07:42:51 +0000</pubDate>
		<dc:creator>art project team</dc:creator>
				<category><![CDATA[フレームワーク]]></category>
		<category><![CDATA[プログラム]]></category>
		<category><![CDATA[メモ]]></category>
		<category><![CDATA[ZendFramework]]></category>

		<guid isPermaLink="false">http://blog.art-p.com/?p=551</guid>
		<description><![CDATA[ZendFrameworkは自由度が高いせいかいろいろ自分で設定しなきゃいけないんのですが、とりあえずDB接続のめも。 いちいちファイルごとにホストネームとか指定するのは現実的ではないので、application.ini [...]]]></description>
			<content:encoded><![CDATA[<p>ZendFrameworkは自由度が高いせいかいろいろ自分で設定しなきゃいけないんのですが、とりあえずDB接続のめも。<br />
いちいちファイルごとにホストネームとか指定するのは現実的ではないので、application.iniとBootstrap.phpでの接続方法。<br />
<span id="more-551"></span><br />
application.iniにデータベースの設定情報を記述。</p>
<p>application/configs/application.ini</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#91;</span>production<span style="color: #009900;">&#93;</span><br />
db<span style="color: #339933;">.</span>adapter <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;PDO_MYSQL&quot;</span><br />
db<span style="color: #339933;">.</span>params<span style="color: #339933;">.</span>host <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;localhost&quot;</span><br />
db<span style="color: #339933;">.</span>params<span style="color: #339933;">.</span>username <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;root&quot;</span><br />
db<span style="color: #339933;">.</span>params<span style="color: #339933;">.</span>password <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;xxxx&quot;</span><br />
db<span style="color: #339933;">.</span>params<span style="color: #339933;">.</span>dbname <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;xxxx&quot;</span><br />
db<span style="color: #339933;">.</span>params<span style="color: #339933;">.</span>charset <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;utf8&quot;</span></div></td></tr></tbody></table></div>
<p>ホスト名などはサーバごとに違うので注意。ローカルの場合はたいてい「localhost」でいけるはず。<br />
dbnameはデータベース名。</p>
<p>application/Bootstrap.php</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000000; font-weight: bold;">class</span> Bootstrap <span style="color: #000000; font-weight: bold;">extends</span> Zend_Application_Bootstrap_Bootstrap<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> _initDb<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; try<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Config<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$dbConfig</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$options</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//データベース設定を取得</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$dbConect</span> <span style="color: #339933;">=</span> Zend_Db<span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbConfig</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">adapter</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbConfig</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; <br />
&nbsp; &nbsp; &nbsp; Zend_Registry<span style="color: #339933;">::</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'db'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbConect</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; Zend_Db_Table<span style="color: #339933;">::</span><span style="color: #004000;">setDefaultAdapter</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbConect</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//データベースに接続</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$dbConect</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span>catch<span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//エラー時の処理</span><br />
&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>これでデータベースに接続できたので間違いないだろう。<br />
エラー処理を本番環境と開発環境で分けたい場合はエラー処理の所を</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:100%;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'production'</span> <span style="color: #339933;">==</span> APPLICATION_ENV<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">//本番環境でのエラーメッセージ</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #666666; font-style: italic;">//開発環境でのエラーメッセージ</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>とすればいい。<br />
1行目の振り分けはpublic/.htaccessに記述している<br />
SetEnv APPLICATION_ENV xxxxxxxxx<br />
のこと。(xxxxxxxxには production か development が入る)</p>
<p>いろいろググった結果なので、もしもっといい方法があれば教えていただけると助かります。<br />
ZendFrameworkの本を買おうかな。。。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.art-p.com/%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0/zendframework%e3%81%a7db%e6%8e%a5%e7%b6%9a%e3%83%a1%e3%83%a2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.art-p.com/%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0/zendframework%e3%81%a7db%e6%8e%a5%e7%b6%9a%e3%83%a1%e3%83%a2/" />
	</item>
		<item>
		<title>ヘテムルでのZend Framework導入めも</title>
		<link>http://blog.art-p.com/%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0/%e3%83%98%e3%83%86%e3%83%a0%e3%83%ab%e3%81%a7%e3%81%aezend-framework%e5%b0%8e%e5%85%a5%e3%82%81%e3%82%82/</link>
		<comments>http://blog.art-p.com/%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0/%e3%83%98%e3%83%86%e3%83%a0%e3%83%ab%e3%81%a7%e3%81%aezend-framework%e5%b0%8e%e5%85%a5%e3%82%81%e3%82%82/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 05:59:05 +0000</pubDate>
		<dc:creator>art project team</dc:creator>
				<category><![CDATA[フレームワーク]]></category>
		<category><![CDATA[プログラム]]></category>
		<category><![CDATA[メモ]]></category>
		<category><![CDATA[ZendFramework]]></category>

		<guid isPermaLink="false">http://blog.art-p.com/?p=542</guid>
		<description><![CDATA[個人的なメモですが・・・ ヘテムルでZend Frameworkを導入する時のメモ。 ZendFrameworkのライブラリ郡(本家からDLしたファイル)をwebとかappsとかある所にフォルダを作ってぶち込む ↓ we [...]]]></description>
			<content:encoded><![CDATA[<p>個人的なメモですが・・・<br />
ヘテムルでZend Frameworkを導入する時のメモ。</p>
<p><span id="more-542"></span>ZendFrameworkのライブラリ郡(本家からDLしたファイル)をwebとかappsとかある所にフォルダを作ってぶち込む<br />
↓<br />
web/適当なフォルダに(applicationとかpublicフォルダ)を入れる。<br />
↓<br />
.htaccess にphp5で動くように「AddHandler php5-script .php」を記述<br />
↓<br />
index.phpに<br />
$path = &#8220;/home/sites/heteml/(自分のユーザー)/ZendFramework/library&#8221;;<br />
set_include_path(get_include_path() . PATH_SEPARATOR . $path);<br />
と書く。<br />
↓<br />
ヘテムルのコンパネ画面でドメインの設定をweb/適当なフォルダ/public にすれば、一応見れる。</p>
<p>多分これで大丈夫。<br />
今の所見れてるので大丈夫だろう。。。</p>
<p>ディレクトリ構成はこんな感じ<br />
apps/<br />
zendframework/<br />
└library/<br />
web/<br />
└適当なフォルダ<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├application<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├public(ここにドメイン設定をした)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├などなど</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.art-p.com/%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0/%e3%83%98%e3%83%86%e3%83%a0%e3%83%ab%e3%81%a7%e3%81%aezend-framework%e5%b0%8e%e5%85%a5%e3%82%81%e3%82%82/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://blog.art-p.com/%e3%83%97%e3%83%ad%e3%82%b0%e3%83%a9%e3%83%a0/%e3%83%98%e3%83%86%e3%83%a0%e3%83%ab%e3%81%a7%e3%81%aezend-framework%e5%b0%8e%e5%85%a5%e3%82%81%e3%82%82/" />
	</item>
	</channel>
</rss>

