<?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; 技術</title>
	<atom:link href="http://morinoyume.com/category/techs/feed/" rel="self" type="application/rss+xml" />
	<link>http://morinoyume.com</link>
	<description>渋谷で働く若手ＳＥの日々の日記。</description>
	<lastBuildDate>Thu, 11 Feb 2010 05:10:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://morinoyume.com/category/techs/feed/" />
		<item>
		<title>Symfony(1.4)でZendのライブラリを使う。</title>
		<link>http://morinoyume.com/techs/symfony1-4%e3%81%a7zend%e3%81%ae%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e3%82%92%e4%bd%bf%e3%81%86%e3%80%82/</link>
		<comments>http://morinoyume.com/techs/symfony1-4%e3%81%a7zend%e3%81%ae%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e3%82%92%e4%bd%bf%e3%81%86%e3%80%82/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 15:56:16 +0000</pubDate>
		<dc:creator>YSU</dc:creator>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[技術]]></category>

		<guid isPermaLink="false">http://morinoyume.com/?p=415</guid>
		<description><![CDATA[今日はsymfonyでzendのライブラリを使うお話。
zendってのは、pearと同じように色々便利なことができるモジュール群と考えてもよい。
例えば、phpでHTTPリクエストしたり、XMLを解析したり、など一般的な [...]]]></description>
			<content:encoded><![CDATA[<p>今日はsymfonyでzendのライブラリを使うお話。<br />
zendってのは、pearと同じように色々便利なことができるモジュール群と考えてもよい。<br />
例えば、phpでHTTPリクエストしたり、XMLを解析したり、など一般的なものからtwitterやAmazonのapiを扱うものまでかなり便利なものが多い。<br />
種類こそpearより少ないが、使いやすさはpearよりもはるかに使いやすいと思われる。</p>
<p>まずは、zendのインストール。今回は「/usr/local/」配下にインストールする。</p>
<pre class="brush: plain;">
cd /usr/local
wget http://framework.zend.com/releases/ZendFramework-1.10.0/ZendFramework-1.10.0.tar.gz
tar -xvzf ZendFramework-1.10.0.tar.gz
mv ZendFramework-1.10.0 Zend
</pre>
<p>こんな感じ。最後のmvは名前をなんとなく「Zend」にしておきたいだけで、意味はない。<br />
最新のZendは<a href="http://framework.zend.com/download/latest">ココ</a>でチェック。</p>
<p>次にphp.iniに以下を追記する。<br />
これがないとうまく動かない。<br />
(すでにinclude_pathが定義されている場合は「:/usr/local/Zend/library」を足してください。)</p>
<pre class="brush: plain;">
include_path=&quot;.:/usr/local/Zend/library&quot;
</pre>
<p>んで、次にsymfonyのautoload.ymlに以下のように記述する。<br />
autoload.ymlはデフォｒフトでは設置されていないので、アプリケーションのconfigディレクトリの下に作成する。<br />
（プロジェクトのコンフィグ配下でもよいと思われる。）</p>
<pre class="brush: plain;">
autoload:
  # zendframework
  zendframework_lib:
    name:           zendframework lib
    path:           /usr/local/Zend/library
    recursive:      on
</pre>
<p>これで</p>
<pre class="brush: plain;">
symfony cc
</pre>
<p>うって完了。<br />
あとはソース上のすきなとこに</p>
<pre class="brush: plain;">
$twitter = new Zend_Service_Twitter('morinoyume', 'morinoyume');
</pre>
<p>見たいな感じで、zendのライブラリを呼べばＯＫ！簡単♪<br />
上記はzendのtwitter用のライブラリですね。</p>
<p>zendは扱いやすいので、みなさんも是非！</p>
<p>参考:<a href="http://ueblog.natural-wave.com/2008/03/24/symfony-zend-framework/">ueblog</a></p>
<h3  class="related_post_title">関連の記事</h3><ul class="related_post"><li>2010 年 1 月 26 日 -- <a href="http://morinoyume.com/techs/symfony1-4symfony1-3%e3%81%a7%e3%83%90%e3%83%83%e3%83%81%e5%87%a6%e7%90%86/" title="Symfony1.4(Symfony1.3)でバッチ処理">Symfony1.4(Symfony1.3)でバッチ処理</a></li><li>2009 年 11 月 29 日 -- <a href="http://morinoyume.com/techs/propel-schema-reversethere-was-an-error-building-xml-from-metadatacould-not-find-driver/" title="[propel-schema-reverse]there was an error building XML from metadata:could not find driver">[propel-schema-reverse]there was an error building XML from metadata:could not find driver</a></li><li>2010 年 1 月 30 日 -- <a href="http://morinoyume.com/techs/php%e3%81%a7twitter%e3%81%ab%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8f%e3%80%82servicestwitter-php/" title="phpでtwitterにつぶやく。(&#8221;Services/Twitter.php&#8221;)">phpでtwitterにつぶやく。(&#8221;Services/Twitter.php&#8221;)</a></li><li>2010 年 1 月 20 日 -- <a href="http://morinoyume.com/techs/php%e3%81%ae%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%83%a9%e3%82%a4%e3%83%b3%e3%81%a7argv%e3%81%8cnull%e3%81%ae%e3%81%be%e3%81%be%ef%bc%88php-notice-undefined-variable-argv%ef%bc%89/" title="PHPのコマンドラインで$argvがNULLのまま（PHP Notice: Undefined variable: argv）">PHPのコマンドラインで$argvがNULLのまま（PHP Notice: Undefined variable: argv）</a></li><li>2010 年 1 月 18 日 -- <a href="http://morinoyume.com/techs/ethna%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/" title="Ethnaをインストールしてみた。">Ethnaをインストールしてみた。</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://morinoyume.com/techs/symfony1-4%e3%81%a7zend%e3%81%ae%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e3%82%92%e4%bd%bf%e3%81%86%e3%80%82/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://morinoyume.com/techs/symfony1-4%e3%81%a7zend%e3%81%ae%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e3%82%92%e4%bd%bf%e3%81%86%e3%80%82/" />
	</item>
		<item>
		<title>phpでtwitterにつぶやく。(&#8221;Services/Twitter.php&#8221;)</title>
		<link>http://morinoyume.com/techs/php%e3%81%a7twitter%e3%81%ab%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8f%e3%80%82servicestwitter-php/</link>
		<comments>http://morinoyume.com/techs/php%e3%81%a7twitter%e3%81%ab%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8f%e3%80%82servicestwitter-php/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 01:37:01 +0000</pubDate>
		<dc:creator>YSU</dc:creator>
				<category><![CDATA[twitter]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://morinoyume.com/?p=408</guid>
		<description><![CDATA[今日はphpでtwitterに呟く方法を書く。
twitterはapiで呟けるが、phpにはpearに（Services/Twitter.php）という便利なモジュールがあるので、
今回はそれを使う。細かい使い方はココが [...]]]></description>
			<content:encoded><![CDATA[<p>今日はphpでtwitterに呟く方法を書く。<br />
twitterはapiで呟けるが、phpにはpearに（Services/Twitter.php）という便利なモジュールがあるので、<br />
今回はそれを使う。細かい使い方は<a href="http://labs.transrain.net/products/services_twitter/">ココ</a>が詳しい。<br />
まずは.pearの"Services/Twitter.php"が無いと話にならない。インストール。</p>
<pre class="brush: plain;">
  pear install --alldeps -f http://labs.transrain.net/files/Services_Twitter-0.4.0.tgz
</pre>
<p>以下は呟くときのサンプルソース。ID,Password,呟きたい内容を引数に渡せば勝手に呟いてくれる関数だ。<br />
140文字を超えている場合は135文字に切って「...」をつけてくれる。<br />
*phpインストール時に"--enable-mbstring"オプションがないと、140文字の部分が動かないかも。</p>
<pre class="brush: plain;">
  public static function tweet($id = null , $pass = null ,  $tweet )
  {
    //ServicesTwitterの読み込み。
    require_once &quot;Services/Twitter.php&quot;;

    //140文字を超えていたら、135文字で切って...をつける。
    if(mb_strlen($tweet)&gt; 140 )
    {
      $tweet = mb_substr( $tweet , 0 , 135 );
      $tweet .= &quot;... &quot;;
    }

    $st =&amp; new Services_Twitter( $id , $pass );
    $st-&gt;setUpdate($tweet);
  }
</pre>
<p>あとは、呼び出し側で、</p>
<pre class="brush: plain;">
self::tweet(&quot;morinoyume&quot; , &quot;morinoyume&quot; , &quot;森の夢だよーん&quot;)
</pre>
<p>とでもやれば、morinoyumeアカウントに呟かれるだろう。<br />
twitterのＡＰＩ簡単だね。もっと勉強していきます！</p>
<h3  class="related_post_title">関連の記事</h3><ul class="related_post"><li>2010 年 2 月 7 日 -- <a href="http://morinoyume.com/techs/symfony1-4%e3%81%a7zend%e3%81%ae%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e3%82%92%e4%bd%bf%e3%81%86%e3%80%82/" title="Symfony(1.4)でZendのライブラリを使う。">Symfony(1.4)でZendのライブラリを使う。</a></li><li>2010 年 1 月 26 日 -- <a href="http://morinoyume.com/techs/symfony1-4symfony1-3%e3%81%a7%e3%83%90%e3%83%83%e3%83%81%e5%87%a6%e7%90%86/" title="Symfony1.4(Symfony1.3)でバッチ処理">Symfony1.4(Symfony1.3)でバッチ処理</a></li><li>2010 年 1 月 20 日 -- <a href="http://morinoyume.com/techs/php%e3%81%ae%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%83%a9%e3%82%a4%e3%83%b3%e3%81%a7argv%e3%81%8cnull%e3%81%ae%e3%81%be%e3%81%be%ef%bc%88php-notice-undefined-variable-argv%ef%bc%89/" title="PHPのコマンドラインで$argvがNULLのまま（PHP Notice: Undefined variable: argv）">PHPのコマンドラインで$argvがNULLのまま（PHP Notice: Undefined variable: argv）</a></li><li>2010 年 1 月 18 日 -- <a href="http://morinoyume.com/techs/ethna%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/" title="Ethnaをインストールしてみた。">Ethnaをインストールしてみた。</a></li><li>2009 年 11 月 29 日 -- <a href="http://morinoyume.com/techs/phpmyadmin%e3%81%a7%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%af%e3%81%aa%e3%81%84%e3%81%8c%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%a7%e3%81%8d%e3%81%aa%e3%81%84%e7%8f%be%e8%b1%a1%e3%81%ab%e3%81%a4%e3%81%84/" title="phpMyAdminでエラーはないがログインできない現象について">phpMyAdminでエラーはないがログインできない現象について</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://morinoyume.com/techs/php%e3%81%a7twitter%e3%81%ab%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8f%e3%80%82servicestwitter-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://morinoyume.com/techs/php%e3%81%a7twitter%e3%81%ab%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8f%e3%80%82servicestwitter-php/" />
	</item>
		<item>
		<title>Symfony1.4(Symfony1.3)でバッチ処理</title>
		<link>http://morinoyume.com/techs/symfony1-4symfony1-3%e3%81%a7%e3%83%90%e3%83%83%e3%83%81%e5%87%a6%e7%90%86/</link>
		<comments>http://morinoyume.com/techs/symfony1-4symfony1-3%e3%81%a7%e3%83%90%e3%83%83%e3%83%81%e5%87%a6%e7%90%86/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 15:24:23 +0000</pubDate>
		<dc:creator>YSU</dc:creator>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[ニュース・時事]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://morinoyume.com/?p=402</guid>
		<description><![CDATA[http://www.sylvan-l.net/b/2009/01/14/symfony12でバッチ処理を作るにはどうすればいいの？/]]></description>
			<content:encoded><![CDATA[<p>symfony1.0はバッチファイルを作って、symfonyをイニシャライズして、コマンドを実行するというものであった。<br />
symfony1.2からはバッチ処理はsymfonyのタスクで行うことになっている。<br />
1.0ユーザーの私は困惑したので、記事にしておく。</p>
<p>今回はターミナルに「Hello World」を表示する簡単なタスクを作ってみることにする。</p>
<p>まずは、ベースとなるタスクの作成。</p>
<pre class="brush: plain;">
symfony generate:task helloworld
</pre>
<p>すると、lib/task/helloworldTask.class.php<br />
というファイルができるので、</p>
<pre class="brush: plain;">
$this-&gt;namespace        = 'batch';
$this-&gt;name             = 'helloworld';
</pre>
<p>と適当にnamespaceとnameをふっておく。</p>
<pre class="brush: plain;">
// add your code here
echo &quot;Hello World!!&quot;;
</pre>
<p>そして、add youre code hereの部分に上記のように記述。<br />
あとは、タスクで実行するだけ。</p>
<pre class="brush: plain;">
symfony batch:helloworld
&gt;Hello World!!
</pre>
<p>symfonyコマンドでバッチ処理ができている。<br />
なんか素敵♪</p>
<h3  class="related_post_title">関連の記事</h3><ul class="related_post"><li>2010 年 2 月 7 日 -- <a href="http://morinoyume.com/techs/symfony1-4%e3%81%a7zend%e3%81%ae%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e3%82%92%e4%bd%bf%e3%81%86%e3%80%82/" title="Symfony(1.4)でZendのライブラリを使う。">Symfony(1.4)でZendのライブラリを使う。</a></li><li>2009 年 11 月 29 日 -- <a href="http://morinoyume.com/techs/propel-schema-reversethere-was-an-error-building-xml-from-metadatacould-not-find-driver/" title="[propel-schema-reverse]there was an error building XML from metadata:could not find driver">[propel-schema-reverse]there was an error building XML from metadata:could not find driver</a></li><li>2010 年 1 月 30 日 -- <a href="http://morinoyume.com/techs/php%e3%81%a7twitter%e3%81%ab%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8f%e3%80%82servicestwitter-php/" title="phpでtwitterにつぶやく。(&#8221;Services/Twitter.php&#8221;)">phpでtwitterにつぶやく。(&#8221;Services/Twitter.php&#8221;)</a></li><li>2010 年 1 月 20 日 -- <a href="http://morinoyume.com/techs/php%e3%81%ae%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%83%a9%e3%82%a4%e3%83%b3%e3%81%a7argv%e3%81%8cnull%e3%81%ae%e3%81%be%e3%81%be%ef%bc%88php-notice-undefined-variable-argv%ef%bc%89/" title="PHPのコマンドラインで$argvがNULLのまま（PHP Notice: Undefined variable: argv）">PHPのコマンドラインで$argvがNULLのまま（PHP Notice: Undefined variable: argv）</a></li><li>2010 年 1 月 18 日 -- <a href="http://morinoyume.com/techs/ethna%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/" title="Ethnaをインストールしてみた。">Ethnaをインストールしてみた。</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://morinoyume.com/techs/symfony1-4symfony1-3%e3%81%a7%e3%83%90%e3%83%83%e3%83%81%e5%87%a6%e7%90%86/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://morinoyume.com/techs/symfony1-4symfony1-3%e3%81%a7%e3%83%90%e3%83%83%e3%83%81%e5%87%a6%e7%90%86/" />
	</item>
		<item>
		<title>PHPのコマンドラインで$argvがNULLのまま（PHP Notice: Undefined variable: argv）</title>
		<link>http://morinoyume.com/techs/php%e3%81%ae%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%83%a9%e3%82%a4%e3%83%b3%e3%81%a7argv%e3%81%8cnull%e3%81%ae%e3%81%be%e3%81%be%ef%bc%88php-notice-undefined-variable-argv%ef%bc%89/</link>
		<comments>http://morinoyume.com/techs/php%e3%81%ae%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%83%a9%e3%82%a4%e3%83%b3%e3%81%a7argv%e3%81%8cnull%e3%81%ae%e3%81%be%e3%81%be%ef%bc%88php-notice-undefined-variable-argv%ef%bc%89/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 15:52:29 +0000</pubDate>
		<dc:creator>YSU</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[技術]]></category>

		<guid isPermaLink="false">http://morinoyume.com/?p=398</guid>
		<description><![CDATA[今日はエラー系の投稿。
phpでバッチを作成していた際にコマンドラインの引数が渡らないというお話。
phpのコマンドライン引数についてはこちらを参照。
test.php

&#60;?php
echo $argv[1];
 [...]]]></description>
			<content:encoded><![CDATA[<p>今日はエラー系の投稿。<br />
phpでバッチを作成していた際にコマンドラインの引数が渡らないというお話。<br />
phpのコマンドライン引数については<a href="http://php.net/manual/ja/reserved.variables.argv.php">こちら</a>を参照。</p>
<p>test.php</p>
<pre class="brush: plain;">
&lt;?php
echo $argv[1];
?&gt;
</pre>
<p>例えば、上記スクリプトの場合</p>
<pre class="brush: plain;">
php test.php &quot;Hello World!&quot;
</pre>
<p>と入力すれば、「Hello World!」とターミナルに出力されるはずである。<br />
しかし、</p>
<pre class="brush: plain;">
PHP Notice: Undefined variable: argv
</pre>
<p>となってしまい、argvそのものが定義されていないようだ・・・。<br />
原因はphp.ini。</p>
<pre class="brush: plain;">
register_argc_argv = Off
</pre>
<p>となっていたら</p>
<pre class="brush: plain;">
register_argc_argv = On
</pre>
<p>としよう。これで解決。<br />
以外と日本語のドキュメントがなかったので、残しておく。</p>
<h3  class="related_post_title">関連の記事</h3><ul class="related_post"><li>2010 年 2 月 7 日 -- <a href="http://morinoyume.com/techs/symfony1-4%e3%81%a7zend%e3%81%ae%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e3%82%92%e4%bd%bf%e3%81%86%e3%80%82/" title="Symfony(1.4)でZendのライブラリを使う。">Symfony(1.4)でZendのライブラリを使う。</a></li><li>2010 年 1 月 30 日 -- <a href="http://morinoyume.com/techs/php%e3%81%a7twitter%e3%81%ab%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8f%e3%80%82servicestwitter-php/" title="phpでtwitterにつぶやく。(&#8221;Services/Twitter.php&#8221;)">phpでtwitterにつぶやく。(&#8221;Services/Twitter.php&#8221;)</a></li><li>2010 年 1 月 26 日 -- <a href="http://morinoyume.com/techs/symfony1-4symfony1-3%e3%81%a7%e3%83%90%e3%83%83%e3%83%81%e5%87%a6%e7%90%86/" title="Symfony1.4(Symfony1.3)でバッチ処理">Symfony1.4(Symfony1.3)でバッチ処理</a></li><li>2010 年 1 月 18 日 -- <a href="http://morinoyume.com/techs/ethna%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/" title="Ethnaをインストールしてみた。">Ethnaをインストールしてみた。</a></li><li>2009 年 11 月 29 日 -- <a href="http://morinoyume.com/techs/phpmyadmin%e3%81%a7%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%af%e3%81%aa%e3%81%84%e3%81%8c%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%a7%e3%81%8d%e3%81%aa%e3%81%84%e7%8f%be%e8%b1%a1%e3%81%ab%e3%81%a4%e3%81%84/" title="phpMyAdminでエラーはないがログインできない現象について">phpMyAdminでエラーはないがログインできない現象について</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://morinoyume.com/techs/php%e3%81%ae%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%83%a9%e3%82%a4%e3%83%b3%e3%81%a7argv%e3%81%8cnull%e3%81%ae%e3%81%be%e3%81%be%ef%bc%88php-notice-undefined-variable-argv%ef%bc%89/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://morinoyume.com/techs/php%e3%81%ae%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%83%a9%e3%82%a4%e3%83%b3%e3%81%a7argv%e3%81%8cnull%e3%81%ae%e3%81%be%e3%81%be%ef%bc%88php-notice-undefined-variable-argv%ef%bc%89/" />
	</item>
		<item>
		<title>Ethnaをインストールしてみた。</title>
		<link>http://morinoyume.com/techs/ethna%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/</link>
		<comments>http://morinoyume.com/techs/ethna%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 03:35:10 +0000</pubDate>
		<dc:creator>YSU</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[Ethna]]></category>

		<guid isPermaLink="false">http://morinoyume.com/?p=390</guid>
		<description><![CDATA[基本的に私はPHPで開発するときはSymfonyだが、今回Ethnaを入れてみた。
今回はそのEthnaについて思いのまま書いてみる。
基本的にはココを見れば一通りのドキュメントがそろっているので、
そちらを見たほうがよ [...]]]></description>
			<content:encoded><![CDATA[<p>基本的に私はPHPで開発するときはSymfonyだが、今回Ethnaを入れてみた。<br />
今回はそのEthnaについて思いのまま書いてみる。<br />
基本的には<a href="http://ethna.jp/">ココ</a>を見れば一通りのドキュメントがそろっているので、<br />
そちらを見たほうがよいだろう。</p>
<h2>Ethnaとは</h2>
<p>Ethna(えすな)とは、Greeが開発した和製のPHPフレームワークである。<br />
日本でＰＨＰフレームワークといったら、Cake , Symfony , Zendなんかがポピュラーだが、Ethnaはそれに続く立ち位置だと思う。<br />
和製ＰＨＰﾌﾚｰﾑﾜｰｸとしては、一番使われていると思われる。もちろんGREEもEthnaを使ってできている。</p>
<h2>Ethnaをインストール</h2>
<p>インストールはPearでサクッと入る。</p>
<pre class="brush: plain;">
pear channel-discover pear.ethna.jp
pear update-channels
pear install -a ethna/ethna
</pre>
<p>上記コマンドで打ったら</p>
<pre class="brush: plain;">
/usr/share/pear
</pre>
<p>以下にEthnaのソースが展開されたので、ここにphpのパスを通しておく必要がある。<br />
php.iniに以下を追加。</p>
<pre class="brush: plain;">
include_path=&quot;.:/usr/share/pear&quot;
</pre>
<p>ethnaが入っているか確認</p>
<pre class="brush: plain;">
ethna -v
Ethna 2.5.0 (using PHP 5.2.9)
</pre>
<h2>Ethnaを使ってみて思った全体感</h2>
<p>まず思ったことは、フレームワークはやりのＭＶＣがしっかりしている。<br />
<a href="http://ethna.jp/">公式ドキュメント</a>を見ても分かるが、<br />
コントローラーやアクションに余計なものは書かないように推奨されている。(アクションに２００行以上書いちゃだめとか)<br />
逆に言うと、MVCって何？的な人がEthnaを使えばMVCってのが何となく理解できるのではないだろうか。</p>
<h2>Ethnaのテンプレートエンジン Smarty</h2>
<p>Ethnaの特徴の一つは、テンプレートエンジンとしてsmartyを採用している。<br />
また、バリデート時のエラーメッセージやformのデフォルト値、viewオブジェクトでセットした値が非常にアクセスしやすくなっている。<br />
さらに、ユーザーが入力したform値に関してはデフォルトでエスケープ処理がされているという便利設計。<br />
しかし、ヘッダー、フッターを都度かからなければならずsymfonyのlayout.phpみたいな便利な機能がない。<br />
ヘッダー、フッターのインクルードファイルを作るほかないだろう。</p>
<h2>Ethnaの文字コード</h2>
<p>当初はEUC-JPがデフォルトだったが、最新版ではUTF-8がデフォルト。<br />
やはりUTF-8がよい。</p>
<h2>EthnaのＤＢ接続</h2>
<p>ﾒｲﾝはPEAR::DBを継承したEthna_DB_PEARを使っている。<br />
whileでresultセットを回して、１件、１件fetchする感じ。<br />
直感的にＳＱＬをかけるのは良い。<br />
便利なことに、マスター用の接続、スレーブ用の接続（複数セットした場合は自動で振分け機能付き）など色々な接続を簡単に設定できる。</p>
<p>一応、O/Rマッパーも独自で実装されている。<br />
ぱっと見は使いやすそうだが、やはりSymfonyのマッパー等にくらべると少々弱い感じがする・・・。<br />
オブジェクトの配列を一気に取得して、がんがん回して、がんがんセットしていきたい。見た目、一つずつしか取得できない？<br />
ただ、webのform値を一気にimport(set)できるのは便利そう！スクリプトが綺麗になる。</p>
<h2>コレは便利formについて</h2>
<p>チュートリアルをサクッと見ると、すごく便利に見えたのはformについて。<br />
formのバリデートはそれ専用に書くところがあるし、エラーハンドリングやエラーメッセージもテンプレート側でsmartyを使ってアクセスしやすい。またエラー時にvalue値としてformの値をセットするが、デフォルトでエスケープされている。<br />
また、バリーデート済みのform値はO/Rマッパーを使用してそのままオブジェクトにset->updateできる。</p>
<p>symfonyにも同様の機能があるが、こちらの方がテンプレートも自由にかける等少しライトに実装されており、つかいやすそう。</p>
<h2>Ethnaのパフォーマンス</h2>
<p>symfonyとethnaで「Hello World」を出力するアプリを作ってみて、各１０回計測し、それの平均値をもとめてみた。</p>
<ul>
<li>Ethna : 0.0724179</li>
<li>Symfony : 0.0970384</li>
</ul>
<p>すくなくともsymfonyより早いので問題ないでしょう。symfonyが重すぎ・・・。<br />
あとはＤＢ接続周りに依存するでしょうね。</p>
<h2>まとめ</h2>
<p>とりあえず思ったことは、EthnaはライトなWebアプリケーションを作るのにはすごく向いているなと思う。<br />
また、全体的に分かりやすいので習得コストもそれほどかからないだろう。<br />
ただし、Symfonyなどと比べるとやはり機能が少ない（symfonyが多すぎ）。<br />
もし、大規模なアプリケーションを開発するのであれば、EthnaではなくSymfonyなどを検討してみても良いと思う。</p>
<h3  class="related_post_title">関連の記事</h3><ul class="related_post"><li>2010 年 2 月 7 日 -- <a href="http://morinoyume.com/techs/symfony1-4%e3%81%a7zend%e3%81%ae%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e3%82%92%e4%bd%bf%e3%81%86%e3%80%82/" title="Symfony(1.4)でZendのライブラリを使う。">Symfony(1.4)でZendのライブラリを使う。</a></li><li>2010 年 1 月 30 日 -- <a href="http://morinoyume.com/techs/php%e3%81%a7twitter%e3%81%ab%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8f%e3%80%82servicestwitter-php/" title="phpでtwitterにつぶやく。(&#8221;Services/Twitter.php&#8221;)">phpでtwitterにつぶやく。(&#8221;Services/Twitter.php&#8221;)</a></li><li>2010 年 1 月 26 日 -- <a href="http://morinoyume.com/techs/symfony1-4symfony1-3%e3%81%a7%e3%83%90%e3%83%83%e3%83%81%e5%87%a6%e7%90%86/" title="Symfony1.4(Symfony1.3)でバッチ処理">Symfony1.4(Symfony1.3)でバッチ処理</a></li><li>2010 年 1 月 20 日 -- <a href="http://morinoyume.com/techs/php%e3%81%ae%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%83%a9%e3%82%a4%e3%83%b3%e3%81%a7argv%e3%81%8cnull%e3%81%ae%e3%81%be%e3%81%be%ef%bc%88php-notice-undefined-variable-argv%ef%bc%89/" title="PHPのコマンドラインで$argvがNULLのまま（PHP Notice: Undefined variable: argv）">PHPのコマンドラインで$argvがNULLのまま（PHP Notice: Undefined variable: argv）</a></li><li>2009 年 11 月 29 日 -- <a href="http://morinoyume.com/techs/phpmyadmin%e3%81%a7%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%af%e3%81%aa%e3%81%84%e3%81%8c%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%a7%e3%81%8d%e3%81%aa%e3%81%84%e7%8f%be%e8%b1%a1%e3%81%ab%e3%81%a4%e3%81%84/" title="phpMyAdminでエラーはないがログインできない現象について">phpMyAdminでエラーはないがログインできない現象について</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://morinoyume.com/techs/ethna%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://morinoyume.com/techs/ethna%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/" />
	</item>
		<item>
		<title>mysqlパーティショニングのまとめ③- パフォーマンス</title>
		<link>http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a2-%e3%83%91%e3%83%95%e3%82%a9%e3%83%bc%e3%83%9e%e3%83%b3%e3%82%b9/</link>
		<comments>http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a2-%e3%83%91%e3%83%95%e3%82%a9%e3%83%bc%e3%83%9e%e3%83%b3%e3%82%b9/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 18:28:26 +0000</pubDate>
		<dc:creator>YSU</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[サーバー構築]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[まとめ]]></category>

		<guid isPermaLink="false">http://morinoyume.com/?p=353</guid>
		<description><![CDATA[ mysqlパーティショニングのまとめ① - 設定・再コンパイル
 mysqlパーティショニングのまとめ② - パーティショニングのタイプ
mysqlパーティショニングのまとめ③ - パフォーマンス
さて、前回まではパー [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://morinoyume.com/techs/mysql%E3%83%91%E3%83%BC%E3%83%86%E3%82%A3%E3%82%B7%E3%83%A7%E3%83%8B%E3%83%B3%E3%82%B0%E3%81%AE%E3%81%BE%E3%81%A8%E3%82%81%E2%91%A0-%E8%A8%AD%E5%AE%9A%E3%83%BB%E5%86%8D%E3%82%B3%E3%83%B3%E3%83%91/"> mysqlパーティショニングのまとめ① - 設定・再コンパイル</a><br />
<a href="http://morinoyume.com/techs/mysql%E3%83%91%E3%83%BC%E3%83%86%E3%82%A3%E3%82%B7%E3%83%A7%E3%83%8B%E3%83%B3%E3%82%B0%E3%81%AE%E3%81%BE%E3%81%A8%E3%82%81%E2%91%A1-%E3%83%91%E3%83%BC%E3%83%86%E3%82%A3%E3%82%B7%E3%83%A7%E3%83%8B/"> mysqlパーティショニングのまとめ② - パーティショニングのタイプ</a><br />
mysqlパーティショニングのまとめ③ - パフォーマンス</p>
<p>さて、前回まではパーティショニングの設定やパーティショニングのタイプについて述べてきたが、<br />
ここからはパフォーマンスの話をしていく。</p>
<blockquote><p>サンプルテーブル</p></blockquote>
<p>まず、以下のサンプルテーブルを用意した。<br />
それぞれのテーブルに2倍にあたる245746件の郵政省のデータをいれてある。</p>
<p>・postal_normal</p>
<pre class="brush: plain;">
CREATE TABLE postal_normal (
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  `code` int(7) NOT NULL,
  ken_kana varchar(255) DEFAULT NULL,
  ctiy_kana varchar(255) DEFAULT NULL,
  town_kana varchar(255) DEFAULT NULL,
  ken varchar(255) DEFAULT NULL,
  citiy varchar(255) DEFAULT NULL,
  town varchar(255) DEFAULT NULL,
  flg1 tinyint(1) NOT NULL,
  flg2 tinyint(1) NOT NULL,
  flg3 tinyint(1) NOT NULL,
  flg4 tinyint(1) NOT NULL,
  flg5 tinyint(1) NOT NULL,
  flg6 tinyint(1) NOT NULL,
  entry timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  KEY town (town),
  KEY flg1 (flg1),
  KEY entry (entry),
  KEY `code` (`code`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
</pre>
<p>・postal_hash16</p>
<pre class="brush: plain;">
CREATE TABLE postal_hash16 (
  id int(10) unsigned NOT NULL AUTO_INCREMENT,
  `code` int(7) NOT NULL,
  ken_kana varchar(255) DEFAULT NULL,
  ctiy_kana varchar(255) DEFAULT NULL,
  town_kana varchar(255) DEFAULT NULL,
  ken varchar(255) DEFAULT NULL,
  citiy varchar(255) DEFAULT NULL,
  town varchar(255) DEFAULT NULL,
  flg1 tinyint(1) NOT NULL,
  flg2 tinyint(1) NOT NULL,
  flg3 tinyint(1) NOT NULL,
  flg4 tinyint(1) NOT NULL,
  flg5 tinyint(1) NOT NULL,
  flg6 tinyint(1) NOT NULL,
  entry timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  KEY town (town),
  KEY flg1 (flg1),
  KEY entry (entry),
  KEY `code` (`code`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8
PARTITION BY LINEAR HASH (id) PARTITIONS 16;
</pre>
<blockquote><p>テストケース</p></blockquote>
<p>上記のデータに対して、以下のテストを行う。</p>
<ul>
<li>id=240000で検索</li>
<li>id IN (240000, 240001, 240002, 240003, 240004, 240005, 240006, 240007)で検索</li>
<li>code=1000000で検索</li>
<li>ken LIKE '%北海道%'</li>
<li>１レコード追加</li>
</ul>
<blockquote><p>id=240000で検索</p></blockquote>
<p>・パーティショニング</p>
<pre class="brush: plain;">
select * from postal_hash16 where id = 240000;
1 row in set (0.02 sec)
</pre>
<p>・ノーマル</p>
<pre class="brush: plain;">
select * from postal_normal where id = 240000;
1 row in set (0.01 sec)
</pre>
<p>さすがに、パーティションしていないとはいえインデックスの効いたたかが24万件なので差はあまり無いと思われる。<br />
ただ、パーティションしてあるほうはたかだか1万ちょっとからの検索になるはずなので早いはずだが・・・</p>
<blockquote><p>id IN (240000, 240001, 240002, 240003, 240004, 240005, 240006, 240007)で検索</p></blockquote>
<p>・パーティショニング</p>
<pre class="brush: plain;">
select * from postal_hash16 where id IN (240000, 240001, 240002, 240003, 240004, 240005, 240006, 240007);
8 rows in set (0.00 sec);
</pre>
<p>・ノーマル</p>
<pre class="brush: plain;">
select * from postal_normal where id  IN (240000, 240001, 240002, 240003, 240004, 240005, 240006, 240007);
8 rows in set (0.00 sec)
</pre>
<p>うーん・・・検索件数を増やしてもスピードは変わらず・・・<br />
やはり24万件程度では差がでないということか。</p>
<blockquote><p>code=1000000で検索</p></blockquote>
<p>・パーティショニング</p>
<pre class="brush: plain;">
 select * from postal_hash16 where code = 1000000;
2 rows in set (0.26 sec)
</pre>
<p>・ノーマル</p>
<pre class="brush: plain;">
 select * from postal_normal where code = 1000000;
2 rows in set (0.03 sec)
</pre>
<p>これは違いがはっきり出た。<br />
やはりパーティションしているほうが遅いということである。この場合インデックスは効いていないのかも・・・。</p>
<blockquote><p>ken LIKE '%北海道%'で検索</p></blockquote>
<p>・パーティショニング</p>
<pre class="brush: plain;">
 select * from postal_hash16 where ken LIKE '%北海道%'
16454 rows in set (2.34 sec)
</pre>
<p>・ノーマル</p>
<pre class="brush: plain;">
 select * from postal_normal where ken LIKE '%北海道%'
16454 rows in set (1.74 sec)
</pre>
<p>なるほど、インデックスの効いていないカラムに対しては、<br />
ノーマルもやはり遅いが、やはりパーティショニングしている方が遅い結果になった。</p>
<blockquote><p>１レコード追加</p></blockquote>
<p>・パーティショニング</p>
<pre class="brush: plain;">
INSERT INTO `test2`.`postal_hash16` (`code`, `ken_kana`, `ctiy_kana`, `town_kana`, `ken`, `citiy`, `town`, `flg1`, `flg2`, `flg3`, `flg4`, `flg5`, `flg6`, `entry`) VALUES ( &quot;9071801&quot;,&quot;ｵｷﾅﾜｹﾝ&quot;,&quot;ﾔｴﾔﾏｸﾞﾝﾖﾅｸﾞﾆﾁﾖｳ&quot;,&quot;ﾖﾅｸﾞﾆ&quot;,&quot;沖縄県&quot;,&quot;八重山郡与那国町&quot;,&quot;与那国&quot;,0,0,0,0,0,0,NOW() );
Query OK, 1 row affected (0.04 sec)
</pre>
<p>・ノーマル</p>
<pre class="brush: plain;">
INSERT INTO `test2`.`postal_normal` (`code`, `ken_kana`, `ctiy_kana`, `town_kana`, `ken`, `citiy`, `town`, `flg1`, `flg2`, `flg3`, `flg4`, `flg5`, `flg6`, `entry`) VALUES ( &quot;9071801&quot;,&quot;ｵｷﾅﾜｹﾝ&quot;,&quot;ﾔｴﾔﾏｸﾞﾝﾖﾅｸﾞﾆﾁﾖｳ&quot;,&quot;ﾖﾅｸﾞﾆ&quot;,&quot;沖縄県&quot;,&quot;八重山郡与那国町&quot;,&quot;与那国&quot;,0,0,0,0,0,0,NOW() );
Query OK, 1 row affected (0.02 sec)
</pre>
<p>パーティショニングを計算してインサートする分どうしても遅くなってしまう。</p>
<blockquote><p>まとめ</p></blockquote>
<p>今回の実験結果では、パーティショニングのキーとなったプライマリキーの検索ではパフォーマンスは同じであったが、<br />
それ以外のカラムの検索ではパフォーマンスが大きく低下してしまう結果になった。<br />
ただし、24万件ではなく、100万件、1000万件レベルのテストになるとパーティショニングした場合のプライマリキーでの検索に効果が見られる可能性はある。</p>
<p>現時点では他のカラムの検索や、インサートなどのパフォーマンスが劇的に落ちてしまうため、24万レコードレベルのテーブルではパーティショニングは導入すべきでないと考える。</p>
<p>もし、使用するとなれば、アクセスログやクエリーログをテーブル化し、データ量がそれこそ何千万件となったときに効果を発揮するのかもしれない。<br />
是非、大容量のデータでテストをしてみたいが、なんせインサートが遅いのとマシンのスペックが追いつかないため今回は見送らせていただく。</p>
<p>実は仕事でパーティショニングを使ってみたかったが、今回のパフォーマンスではなかなか難しそうだなぁ～</p>
<h3  class="related_post_title">関連の記事</h3><ul class="related_post"><li>2009 年 12 月 8 日 -- <a href="http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a1-%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b/" title="mysqlパーティショニングのまとめ② &#8211; パーティショニングのタイプ">mysqlパーティショニングのまとめ② &#8211; パーティショニングのタイプ</a></li><li>2009 年 12 月 8 日 -- <a href="http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a0-%e8%a8%ad%e5%ae%9a%e3%83%bb%e5%86%8d%e3%82%b3%e3%83%b3%e3%83%91/" title="mysqlパーティショニングのまとめ① &#8211; 設定・再コンパイル">mysqlパーティショニングのまとめ① &#8211; 設定・再コンパイル</a></li><li>2010 年 1 月 17 日 -- <a href="http://morinoyume.com/others/2010%e5%b9%b4%e3%81%ae%e7%9b%ae%e6%a8%99%ef%bc%81%ef%bc%81/" title="2010年の目標！！">2010年の目標！！</a></li><li>2009 年 11 月 29 日 -- <a href="http://morinoyume.com/techs/phpmyadmin%e3%81%a7%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%af%e3%81%aa%e3%81%84%e3%81%8c%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%a7%e3%81%8d%e3%81%aa%e3%81%84%e7%8f%be%e8%b1%a1%e3%81%ab%e3%81%a4%e3%81%84/" title="phpMyAdminでエラーはないがログインできない現象について">phpMyAdminでエラーはないがログインできない現象について</a></li><li>2009 年 11 月 28 日 -- <a href="http://morinoyume.com/techs/symfony%e3%81%a7%e3%81%be%e3%81%9a%e3%81%af%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e4%bd%9c%e6%88%90/" title="symfonyでまずはプロジェクト作成">symfonyでまずはプロジェクト作成</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a2-%e3%83%91%e3%83%95%e3%82%a9%e3%83%bc%e3%83%9e%e3%83%b3%e3%82%b9/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a2-%e3%83%91%e3%83%95%e3%82%a9%e3%83%bc%e3%83%9e%e3%83%b3%e3%82%b9/" />
	</item>
		<item>
		<title>mysqlパーティショニングのまとめ② &#8211; パーティショニングのタイプ</title>
		<link>http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a1-%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b/</link>
		<comments>http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a1-%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 18:25:18 +0000</pubDate>
		<dc:creator>YSU</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[サーバー構築]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[まとめ]]></category>

		<guid isPermaLink="false">http://morinoyume.com/?p=338</guid>
		<description><![CDATA[mysqlパーティショニングのまとめ① - 設定・再コンパイル
mysqlパーティショニングのまとめ② - パーティショニングのタイプ
 mysqlパーティショニングのまとめ③ - パフォーマンス
前回の記事では、mys [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://morinoyume.com/techs/mysql%E3%83%91%E3%83%BC%E3%83%86%E3%82%A3%E3%82%B7%E3%83%A7%E3%83%8B%E3%83%B3%E3%82%B0%E3%81%AE%E3%81%BE%E3%81%A8%E3%82%81%E2%91%A0-%E8%A8%AD%E5%AE%9A%E3%83%BB%E5%86%8D%E3%82%B3%E3%83%B3%E3%83%91/">mysqlパーティショニングのまとめ① - 設定・再コンパイル</a><br />
mysqlパーティショニングのまとめ② - パーティショニングのタイプ<br />
<a href="http://morinoyume.com/techs/mysql%E3%83%91%E3%83%BC%E3%83%86%E3%82%A3%E3%82%B7%E3%83%A7%E3%83%8B%E3%83%B3%E3%82%B0%E3%81%AE%E3%81%BE%E3%81%A8%E3%82%81%E2%91%A2-%E3%83%91%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%B3%E3%82%B9/"> mysqlパーティショニングのまとめ③ - パフォーマンス</a><br />
前回の記事では、mysqlのパーティショニングを使うための、mysql本体のセッティングについて述べたが、<br />
今回はパーティショニングの種類について記述していく。</p>
<blockquote><p>サンプルテーブル</p></blockquote>
<p>まず、説明を始める前に今回はサンプルとして、郵政省の郵便番号データを扱う以下のテーブルを用意した。<br />
いろいろカラムが分かれているが、code(郵便番号)にたいして、フラグやら県名を保持しているテーブルだ。</p>
<pre class="brush: plain;">
CREATE TABLE　`postal` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `code` int(7) NOT NULL,
  `ken_kana` varchar(255) DEFAULT NULL,
  `ctiy_kana` varchar(255) DEFAULT NULL,
  `town_kana` varchar(255) DEFAULT NULL,
  `ken` varchar(255) DEFAULT NULL,
  `citiy` varchar(255) DEFAULT NULL,
  `town` varchar(255) DEFAULT NULL,
  `flg1` tinyint(1) NOT NULL,
  `flg2` tinyint(1) NOT NULL,
  `flg3` tinyint(1) NOT NULL,
  `flg4` tinyint(1) NOT NULL,
  `flg5` tinyint(1) NOT NULL,
  `flg6` tinyint(1) NOT NULL,
  `entry` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `town` (`town`),
  KEY `flg1` (`flg1`),
  KEY `entry` (`entry`)
)
DEFAULT CHARSET=utf8
ENGINE=InnoDB;
</pre>
<blockquote><p>パーティショニングの種類</p></blockquote>
<p>さて、本題に入る。<br />
mysqlのパーティショニングには以下の４つのタイプが存在する。</p>
<ul>
<li>RANGEパーティショニング</li>
<li>LISTパーティショニング</li>
<li>[LINEAR] HASHパーティショニング</li>
<li>[LINEAR] KEYパーティショニング</li>
</ul>
<blockquote><p>RANGEパーティショニング</p></blockquote>
<p>LANGEパーティショニングとは、値の範囲を絞って、パーティショニングする方法である。<br />
あくまでも、パーティショニングする値がある程度決まっている場合などに使用できる。<br />
今回は郵便番号は12万レコード前後で推移すると考え、ＩＤを30000毎に区切ってみる。<br />
（サンプルでは、日付で絞る例がおおい）<br />
「ENGINE=InnoDB」の後ろに以下のように書き加える。</p>
<pre class="brush: plain;">
DEFAULT CHARSET=utf8
ENGINE=InnoDB
PARTITION BY RANGE (id) (
PARTITION p1 VALUES LESS THAN (30000),
PARTITION p2 VALUES LESS THAN (60000),
PARTITION p3 VALUES LESS THAN (90000),
PARTITION p4 VALUES LESS THAN MAXVALUE
);
</pre>
<blockquote><p>LISTパーティショニング</p></blockquote>
<p>LISTパーティショニングは、あるカラムの値の候補が決まっている場合に使われる。<br />
例えば、性別、誕生月、などであろうか・・・。<br />
今回はいい例ではないかもしれないが、flg1を1,0に分けてみる。<br />
「ENGINE=InnoDB」の後ろに以下のように書き加える。</p>
<pre class="brush: plain;">
DEFAULT CHARSET=utf8
ENGINE=InnoDB
PARTITION BY LIST (flg1) (
PARTITION p1 VALUES IN (0),
PARTITION p2 VALUES IN (1)
);
</pre>
<p>しかし、これはエラーになる。</p>
<pre class="brush: plain;">
 A PRIMARY KEY must include all columns in the table's partitioning function
</pre>
<p>プライマリーはパーティショニングの定義に入れなければならない・・・とのこと。なんやねん。<br />
といわけで、<a href="http://d.hatena.ne.jp/cloned/20090506">MySQLのパーティショニングで必要そうな工夫</a>を元に以下みたいな書き方をしてみる。</p>
<pre class="brush: plain;">
DEFAULT CHARSET=utf8
ENGINE=InnoDB
PARTITION BY LIST (( id * 0 ) + flg1) (
PARTITION p1 VALUES IN (0),
PARTITION p2 VALUES IN (1)
);
</pre>
<p>うーん・・・いけない・・・。<br />
ちなみに、<a href="http://dev.mysql.com/doc/refman/5.1/ja/partitioning-limitations.html">15.5. パーティショニングの制約と制限</a>によれば、</p>
<div style="color:blue;">「パーティショニング表現内の他のカラムを使用してこのテーブルをパーティショニングしたい場合、まず必要なカラムをプライマリキーに追加するか、プライマリキー自体を破棄することでテーブルを改良しなければいけません。<span style="color:red;">将来的に、この制限をMySQLから取り除く方向で開発を進めています。</span>」</div>
<p>とのこと。是非、取り除いてほしいですね。<br />
どうやらlistを使用するにはprimaryを外さないと使えなさそうだが、いけてなさすぎるので今回はつかわない。</p>
<blockquote><p>[LINEAR] HASHパーティショニング</p></blockquote>
<p>HASHパーティショニングとは、行が格納されるパーティションを算出するのにMOD（剰余）を利用するものである。<br />
RANGEやLISTと違い、あらかじめ値の範囲や候補をしらなくても動的にパーティショニングできる。<br />
また、各パーティショニングのかたよりも無いと思われる。</p>
<p>また、LINER HASHというものがあるが、これは<a href="http://dev.mysql.com/doc/refman/5.1/ja/partitioning-linear-hash.html"><br />
15.2.3.1. LINEAR HASH パーティショニング</a>によれば</p>
<div style="color:blue;">「リニアハッシュによるパーティショニングの利点は、パーティションの追加、削除、結合、そして分裂のスピードアップが図れることです。これは、大量のデータ（テラバイト級）を含むテーブルを取り扱う際に、効果的です。欠点は、通常のハッシュパーティショニングを使用した時に比べデータがパーティションの間で不均等に割り振られていることがあります。」</div>
<p>とのことらしい、だが計算が難しくてよくわからないが<a href="http://nippondanji.blogspot.com/2009/05/linear-hash.html">漢(オトコ)のコンピュータ道</a>によれば、</p>
<div style="color:blue;">「テーブルが大きい場合にはHASH/KEYではなくLINEAR HASH/LINEAR KEYパーティショニングを利用すること。ただしパーティション数は2の累乗で！」</div>
<p>ということらしい。<br />
なので、HASHを使う場合は「ENGINE=InnoDB」の後ろに以下のように書き加えるとよいだろう。<br />
下記の例だと、idをキーにして1024パーティショニングすることになる。<br />
１パーティショニングあたり、120くらい、めっちゃはやそう。<br />
＊1024がパーティショニングの限界値</p>
<pre class="brush: plain;">
DEFAULT CHARSET=utf8
ENGINE=InnoDB
PARTITION BY LINEAR HASH (id) PARTITIONS 1024;
</pre>
<blockquote><p>[LINEAR] KEYパーティショニング</p></blockquote>
<p>KEYパーティショニングはPASSWORD()関数を使ってハッシュ値を算出する。PASSWORD関数を利用するので、文字列に対しても利用することが出来る。が、ここでもPrimaryの制約があり使用できそうにない（ためしていない）。<br />
もし、教科書的に書くなら「ENGINE=InnoDB」の後ろに以下のように書き加える感じだと思う。</p>
<pre class="brush: plain;">
DEFAULT CHARSET=utf8
ENGINE=InnoDB
PARTITION BY LINEAR KEY(ken) PARTITIONS 1024
);
</pre>
<blockquote><p>パーティショニング確認</p></blockquote>
<p>以上がパーティショニングの説明となる。<br />
これらのテーブルのパーティショニングの状態をチェックするには、</p>
<pre class="brush: plain;">
SELECT * FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME=postal
</pre>
<p>というＳＱＬを投げれば確認できる。<br />
では、次回はパーティショニングのパフォーマンスについて述べていこうと思う。</p>
<h3  class="related_post_title">関連の記事</h3><ul class="related_post"><li>2009 年 12 月 8 日 -- <a href="http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a2-%e3%83%91%e3%83%95%e3%82%a9%e3%83%bc%e3%83%9e%e3%83%b3%e3%82%b9/" title="mysqlパーティショニングのまとめ③- パフォーマンス">mysqlパーティショニングのまとめ③- パフォーマンス</a></li><li>2009 年 12 月 8 日 -- <a href="http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a0-%e8%a8%ad%e5%ae%9a%e3%83%bb%e5%86%8d%e3%82%b3%e3%83%b3%e3%83%91/" title="mysqlパーティショニングのまとめ① &#8211; 設定・再コンパイル">mysqlパーティショニングのまとめ① &#8211; 設定・再コンパイル</a></li><li>2010 年 1 月 17 日 -- <a href="http://morinoyume.com/others/2010%e5%b9%b4%e3%81%ae%e7%9b%ae%e6%a8%99%ef%bc%81%ef%bc%81/" title="2010年の目標！！">2010年の目標！！</a></li><li>2009 年 11 月 29 日 -- <a href="http://morinoyume.com/techs/phpmyadmin%e3%81%a7%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%af%e3%81%aa%e3%81%84%e3%81%8c%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%a7%e3%81%8d%e3%81%aa%e3%81%84%e7%8f%be%e8%b1%a1%e3%81%ab%e3%81%a4%e3%81%84/" title="phpMyAdminでエラーはないがログインできない現象について">phpMyAdminでエラーはないがログインできない現象について</a></li><li>2009 年 11 月 28 日 -- <a href="http://morinoyume.com/techs/symfony%e3%81%a7%e3%81%be%e3%81%9a%e3%81%af%e3%83%97%e3%83%ad%e3%82%b8%e3%82%a7%e3%82%af%e3%83%88%e4%bd%9c%e6%88%90/" title="symfonyでまずはプロジェクト作成">symfonyでまずはプロジェクト作成</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a1-%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a1-%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b/" />
	</item>
		<item>
		<title>mysqlパーティショニングのまとめ① &#8211; 設定・再コンパイル</title>
		<link>http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a0-%e8%a8%ad%e5%ae%9a%e3%83%bb%e5%86%8d%e3%82%b3%e3%83%b3%e3%83%91/</link>
		<comments>http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a0-%e8%a8%ad%e5%ae%9a%e3%83%bb%e5%86%8d%e3%82%b3%e3%83%b3%e3%83%91/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 18:22:17 +0000</pubDate>
		<dc:creator>YSU</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[サーバー構築]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[まとめ]]></category>
		<category><![CDATA[インフラ]]></category>
		<category><![CDATA[自宅サーバー]]></category>

		<guid isPermaLink="false">http://morinoyume.com/?p=326</guid>
		<description><![CDATA[mysqlパーティショニングのまとめ① - 設定・再コンパイル
 mysqlパーティショニングのまとめ② - パーティショニングのタイプ
 mysqlパーティショニングのまとめ③ - パフォーマンス
mysqlのパーティ [...]]]></description>
			<content:encoded><![CDATA[<p>mysqlパーティショニングのまとめ① - 設定・再コンパイル<br />
<a href="http://morinoyume.com/techs/mysql%E3%83%91%E3%83%BC%E3%83%86%E3%82%A3%E3%82%B7%E3%83%A7%E3%83%8B%E3%83%B3%E3%82%B0%E3%81%AE%E3%81%BE%E3%81%A8%E3%82%81%E2%91%A1-%E3%83%91%E3%83%BC%E3%83%86%E3%82%A3%E3%82%B7%E3%83%A7%E3%83%8B/"> mysqlパーティショニングのまとめ② - パーティショニングのタイプ</a><br />
<a href="http://morinoyume.com/techs/mysql%E3%83%91%E3%83%BC%E3%83%86%E3%82%A3%E3%82%B7%E3%83%A7%E3%83%8B%E3%83%B3%E3%82%B0%E3%81%AE%E3%81%BE%E3%81%A8%E3%82%81%E2%91%A2-%E3%83%91%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%B3%E3%82%B9/"> mysqlパーティショニングのまとめ③ - パフォーマンス</a></p>
<p>mysqlのパーティショニングを試してみたかったが、<br />
私のmysqlではパーティショニングが使えなかったようなので<br />
今日はmysqlパーティショニングの再コンパイルについて</p>
<p>まずは、mysqlのパーティショニングが使えるかどうか調べる。</p>
<pre class="brush: plain;">
mysql&gt; SHOW VARIABLES LIKE '%PARTITION%' ;
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| have_partitioning | YES   |
+-------------------+-------+
1 row in set (0.01 sec)
</pre>
<p>上記のようにhave_partitioningがYESとなっていたら、パーティショニングが使用可能である。<br />
私は使用不可であったので、再コンパイルしなければならない。</p>
<p>まずは念のためmysqlをストップ</p>
<pre class="brush: plain;">
/usr/local/mysql/share/mysql/mysql.server stop
</pre>
<p>*パスは各自のパスをご確認ください。</p>
<p>以前のコンパイルオプションに</p>
<pre class="brush: plain;">
--with-ndbcluster--with-partition
</pre>
<p>をつけて</p>
<pre class="brush: plain;">
make
make install
</pre>
<p>で再コンパイル完了。<br />
ちなみに、以前のコンパイルオプションは<br />
mysqlのソースがはいっているディレクトリに移動して</p>
<pre class="brush: plain;">
grep &quot;$ ./configure&quot; config.log
</pre>
<p>とでも打てばいいだろう。</p>
<p>あとはmysqlを起動して、パーティショニングが使用できることを確認できればＯＫだ。</p>
<pre class="brush: plain;">
/usr/local/mysql/share/mysql/mysql.server start
</pre>
<p>[おまけ]現在の私のオプション</p>
<pre class="brush: plain;">
--with-charset=utf8
--with-extra-charsets=all
--with-mysqld-user=mysql
--with-innodb
--with-falcon
--with-maria
--with-heap
--with-myisam
--enable-local-infile
--prefix=/usr/local/mysql
--with-unix-socket-path=/tmp/mysql.sock
--with-ndbcluster
--with-partition
--with-blackhole-storage-engine
</pre>
<p>いろんなストレージを試してみたい。</p>
<h3  class="related_post_title">関連の記事</h3><ul class="related_post"><li>2009 年 5 月 30 日 -- <a href="http://morinoyume.com/techs/mysql%e3%81%8c%e7%ab%8b%e3%81%a1%e4%b8%8a%e3%81%8c%e3%82%89%e3%81%aa%e3%81%84%ef%bc%81%ef%bc%88starting-mysqlmanager-of-pid-file-quit-without-updating-fi/" title="mysqlが立ち上がらない！（Starting MySQL.Manager of pid-file quit without updating file)">mysqlが立ち上がらない！（Starting MySQL.Manager of pid-file quit without updating file)</a></li><li>2009 年 4 月 20 日 -- <a href="http://morinoyume.com/techs/mysql60%e3%81%ae%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%83%a1%e3%83%a2/" title="mysql6.0のインストールメモ">mysql6.0のインストールメモ</a></li><li>2009 年 4 月 19 日 -- <a href="http://morinoyume.com/techs/configure-error-no-cursestermcap-library-found/" title="configure: error: No curses/termcap library found">configure: error: No curses/termcap library found</a></li><li>2009 年 12 月 8 日 -- <a href="http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a2-%e3%83%91%e3%83%95%e3%82%a9%e3%83%bc%e3%83%9e%e3%83%b3%e3%82%b9/" title="mysqlパーティショニングのまとめ③- パフォーマンス">mysqlパーティショニングのまとめ③- パフォーマンス</a></li><li>2009 年 12 月 8 日 -- <a href="http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a1-%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b/" title="mysqlパーティショニングのまとめ② &#8211; パーティショニングのタイプ">mysqlパーティショニングのまとめ② &#8211; パーティショニングのタイプ</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a0-%e8%a8%ad%e5%ae%9a%e3%83%bb%e5%86%8d%e3%82%b3%e3%83%b3%e3%83%91/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://morinoyume.com/techs/mysql%e3%83%91%e3%83%bc%e3%83%86%e3%82%a3%e3%82%b7%e3%83%a7%e3%83%8b%e3%83%b3%e3%82%b0%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%e2%91%a0-%e8%a8%ad%e5%ae%9a%e3%83%bb%e5%86%8d%e3%82%b3%e3%83%b3%e3%83%91/" />
	</item>
		<item>
		<title>WordPressにtwitter toolsをインストールしてみた。</title>
		<link>http://morinoyume.com/techs/wordpress%e3%81%abtwitter-tools%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/</link>
		<comments>http://morinoyume.com/techs/wordpress%e3%81%abtwitter-tools%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 03:41:05 +0000</pubDate>
		<dc:creator>YSU</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[プラグイン]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[ワードプレス]]></category>

		<guid isPermaLink="false">http://morinoyume.com/?p=334</guid>
		<description><![CDATA[ひさびさのwordpress関連の投稿。
最近、twitterにはまっているので、ブログの更新をtwitterでつぶやきたいなーとかサイドバーに自分のつぶやき表示したいなーとか思っていたところ、やはりtwitterがらみ [...]]]></description>
			<content:encoded><![CDATA[<p>ひさびさのwordpress関連の投稿。<br />
最近、twitterにはまっているので、ブログの更新をtwitterでつぶやきたいなーとかサイドバーに自分のつぶやき表示したいなーとか思っていたところ、やはりtwitterがらみのプラグンがあった。</p>
<p><a href="http://wordpress.org/extend/plugins/twitter-tools/">twitter tools</a></p>
<p>これをいれると、自分のつぶやきがサイドバーに表示されたり、ブログの更新をtwitterに投稿したり、はたまた自分のつぶやきをblogに投稿できる優れものだ！</p>
<p>導入は以下のとおり<br />
まず、ダウンロード・インストール</p>
<pre class="brush: plain;">
cd wp-content/plugins/
wget http://downloads.wordpress.org/plugin/twitter-tools.2.0.zip
unzip twitter-tools.2.0.zip
rm twitter-tools.2.0.zip
</pre>
<p>これプラグインの導入は完了。<br />
つづいて、管理画面->プラグイン　でtwitter toolsを有効にする。<br />
その後、管理画面->設定->twitter tools　で色々設定できる。</p>
<p>サイドバーに表示する場合は、<br />
管理画面->概観->ウィジット　にtwitter toolsというプラグインがあるので、それをドラッグ＆ドロップすれば完了だ！</p>
<p>というわけで、これを投稿したらtwitterにも反映されるはずだが・・・。</p>
<h3  class="related_post_title">関連の記事</h3><ul class="related_post"><li>2009 年 2 月 3 日 -- <a href="http://morinoyume.com/techs/wordpress%e3%81%a7%e9%96%a2%e9%80%a3%e8%a8%98%e4%ba%8b%e6%a9%9f%e8%83%bd%e3%81%ae%e5%ae%9f%e8%a3%85%ef%bc%88wordpress-related-posts%ef%bc%89/" title="WordPressで関連記事機能の実装（WordPress Related Posts）">WordPressで関連記事機能の実装（WordPress Related Posts）</a></li><li>2009 年 1 月 31 日 -- <a href="http://morinoyume.com/techs/wordpress%e3%81%a7%e3%82%bd%e3%83%bc%e3%82%b9%e8%a1%a8%e7%a4%ba%e3%80%8csyntaxhighlighter%e3%80%8d%e3%82%92%e5%85%a5%e3%82%8c%e3%81%a6%e3%81%bf%e3%82%8b%e3%80%82/" title="Wordpressでソース表示「SyntaxHighlighter」を入れてみる。">Wordpressでソース表示「SyntaxHighlighter」を入れてみる。</a></li><li>2009 年 1 月 22 日 -- <a href="http://morinoyume.com/techs/wordpress/wordpress%e3%81%ae%e3%80%8call-in-one-seo-pack%e3%80%8d%e3%83%97%e3%83%a9%e3%82%b0%e3%82%a4%e3%83%b3%e3%82%92%e5%85%a5%e3%82%8c%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/" title="Wordpressの「All in One SEO Pack」プラグインを入れてみた。">Wordpressの「All in One SEO Pack」プラグインを入れてみた。</a></li><li>2009 年 2 月 15 日 -- <a href="http://morinoyume.com/techs/wordpress/wordpress%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%9f%e3%82%89%e3%82%84%e3%82%8b%e3%81%b9%e3%81%8d%e3%81%93%e3%81%a8%e3%81%ae%e3%81%be%e3%81%a8%e3%82%81%ef%bc%88/" title="Wordpressをインストールしたらやるべきことのまとめ（設定・SEO）">Wordpressをインストールしたらやるべきことのまとめ（設定・SEO）</a></li><li>2009 年 2 月 3 日 -- <a href="http://morinoyume.com/techs/wordpress%e3%82%bb%e3%82%ad%e3%83%a5%e3%83%aa%e3%83%86%e3%82%a3%e5%90%91%e4%b8%8a%e2%91%a1-htaccess%e3%81%a7%e7%ae%a1%e7%90%86%e7%94%bb%e9%9d%a2%e3%81%b8%e3%81%ae%e3%82%a2%e3%82%af%e3%82%bb%e3%82%b9/" title="Wordpressセキュリティ向上②-.htaccessで管理画面へのアクセスをブロックする-">Wordpressセキュリティ向上②-.htaccessで管理画面へのアクセスをブロックする-</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://morinoyume.com/techs/wordpress%e3%81%abtwitter-tools%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://morinoyume.com/techs/wordpress%e3%81%abtwitter-tools%e3%82%92%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f%e3%80%82/" />
	</item>
		<item>
		<title>phpMyAdminでエラーはないがログインできない現象について</title>
		<link>http://morinoyume.com/techs/phpmyadmin%e3%81%a7%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%af%e3%81%aa%e3%81%84%e3%81%8c%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%a7%e3%81%8d%e3%81%aa%e3%81%84%e7%8f%be%e8%b1%a1%e3%81%ab%e3%81%a4%e3%81%84/</link>
		<comments>http://morinoyume.com/techs/phpmyadmin%e3%81%a7%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%af%e3%81%aa%e3%81%84%e3%81%8c%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%a7%e3%81%8d%e3%81%aa%e3%81%84%e7%8f%be%e8%b1%a1%e3%81%ab%e3%81%a4%e3%81%84/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 03:33:14 +0000</pubDate>
		<dc:creator>YSU</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[技術]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[エラー解決]]></category>

		<guid isPermaLink="false">http://morinoyume.com/?p=322</guid>
		<description><![CDATA[前回の記事でapacheのphp.iniのパスを変更したところ、今度はphpMyAdminにログインできなくなった。
ログインしてもなんども同じログイン画面にリダイレクトされてくる。
しかも、エラーログ等にまったく出てな [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://morinoyume.com/techs/%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%83%A9%E3%82%A4%E3%83%B3%E3%81%A8apache%E3%81%AEconfiguration-file-php-ini-path-%E3%81%AE%E3%83%91%E3%82%B9%E3%81%8C%E9%81%95%E3%81%86%E4%BB%B6%E3%81%AB/">前回の記事</a>でapacheのphp.iniのパスを変更したところ、今度はphpMyAdminにログインできなくなった。</p>
<p>ログインしてもなんども同じログイン画面にリダイレクトされてくる。<br />
しかも、エラーログ等にまったく出てないので意味がわからない。<br />
php.iniの読み込みを外すとログインできるので、ＩＤ・ＰＡＳＳなどのmysqlの設定ではなさそうだ。</p>
<p>んで、アクセスログをよく見ると毎回セッションＩＤが違うことに気づく・・・<br />
なるほど、セッションが繋がれていないのね。<br />
php.iniのセッションを見直す。</p>
<pre class="brush: plain;">
session.save_path = &quot;/var/lib/php/session&quot;
</pre>
<p>phpはrootユーザーでインストールして、apacheのユーザーはrootユーザーでもないし、グループも違うのでここには書き込めないはず。<br />
権限を変更。</p>
<pre class="brush: plain;">
chmod 777 /var/lib/php/session
</pre>
<p>無事セッションが繋がり解決しました。<br />
セッションを保存するパスを変更するのもありだと思います。<br />
phpMyAdminだけの問題ではないですね。</p>
<p>あーエラーばっか・・・・</p>
<h3  class="related_post_title">関連の記事</h3><ul class="related_post"><li>2009 年 5 月 30 日 -- <a href="http://morinoyume.com/techs/mcrypt-%e6%8b%a1%e5%bc%b5%e3%82%92%e3%83%ad%e3%83%bc%e3%83%89%e3%81%a7%e3%81%8d%e3%81%be%e3%81%9b%e3%82%93%e3%80%82php-%e3%81%ae%e8%a8%ad%e5%ae%9a%e3%82%92%e7%a2%ba%e8%aa%8d%e3%81%97%e3%81%a6%e3%81%8f/" title="mcrypt 拡張をロードできません。PHP の設定を確認してください。">mcrypt 拡張をロードできません。PHP の設定を確認してください。</a></li><li>2010 年 2 月 7 日 -- <a href="http://morinoyume.com/techs/symfony1-4%e3%81%a7zend%e3%81%ae%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e3%82%92%e4%bd%bf%e3%81%86%e3%80%82/" title="Symfony(1.4)でZendのライブラリを使う。">Symfony(1.4)でZendのライブラリを使う。</a></li><li>2010 年 1 月 30 日 -- <a href="http://morinoyume.com/techs/php%e3%81%a7twitter%e3%81%ab%e3%81%a4%e3%81%b6%e3%82%84%e3%81%8f%e3%80%82servicestwitter-php/" title="phpでtwitterにつぶやく。(&#8221;Services/Twitter.php&#8221;)">phpでtwitterにつぶやく。(&#8221;Services/Twitter.php&#8221;)</a></li><li>2010 年 1 月 26 日 -- <a href="http://morinoyume.com/techs/symfony1-4symfony1-3%e3%81%a7%e3%83%90%e3%83%83%e3%83%81%e5%87%a6%e7%90%86/" title="Symfony1.4(Symfony1.3)でバッチ処理">Symfony1.4(Symfony1.3)でバッチ処理</a></li><li>2010 年 1 月 20 日 -- <a href="http://morinoyume.com/techs/php%e3%81%ae%e3%82%b3%e3%83%9e%e3%83%b3%e3%83%89%e3%83%a9%e3%82%a4%e3%83%b3%e3%81%a7argv%e3%81%8cnull%e3%81%ae%e3%81%be%e3%81%be%ef%bc%88php-notice-undefined-variable-argv%ef%bc%89/" title="PHPのコマンドラインで$argvがNULLのまま（PHP Notice: Undefined variable: argv）">PHPのコマンドラインで$argvがNULLのまま（PHP Notice: Undefined variable: argv）</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://morinoyume.com/techs/phpmyadmin%e3%81%a7%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%af%e3%81%aa%e3%81%84%e3%81%8c%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%a7%e3%81%8d%e3%81%aa%e3%81%84%e7%8f%be%e8%b1%a1%e3%81%ab%e3%81%a4%e3%81%84/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://morinoyume.com/techs/phpmyadmin%e3%81%a7%e3%82%a8%e3%83%a9%e3%83%bc%e3%81%af%e3%81%aa%e3%81%84%e3%81%8c%e3%83%ad%e3%82%b0%e3%82%a4%e3%83%b3%e3%81%a7%e3%81%8d%e3%81%aa%e3%81%84%e7%8f%be%e8%b1%a1%e3%81%ab%e3%81%a4%e3%81%84/" />
	</item>
	</channel>
</rss>
