<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>へっぽこ開発室 &#187; Zend_Db_Table</title>
	<atom:link href="http://wp.foliz.net/archives/tag/zend_db_table/feed" rel="self" type="application/rss+xml" />
	<link>http://wp.foliz.net</link>
	<description>webプログラム　php,Smarty,Zend Framework,ajax,pearネタなど～</description>
	<lastBuildDate>Sat, 21 Jan 2012 06:32:52 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Zend_Db_Table スキーマバグ</title>
		<link>http://wp.foliz.net/archives/459</link>
		<comments>http://wp.foliz.net/archives/459#comments</comments>
		<pubDate>Thu, 17 Nov 2011 03:58:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ZendFramework]]></category>
		<category><![CDATA[Zend_Db_Table]]></category>

		<guid isPermaLink="false">http://wp.foliz.net/?p=459</guid>
		<description><![CDATA[Zend_Db_Tableで1つのデフォルトスキーマを使ったDbアダプタで スキーマを設定したときfindManyToManyRowset()、findDependantRowset()がどうしても適切なスキーマを実行し [...]]]></description>
			<content:encoded><![CDATA[<p>Zend_Db_Tableで1つのデフォルトスキーマを使ったDbアダプタで<br />
スキーマを設定したときfindManyToManyRowset()、findDependantRowset()がどうしても適切なスキーマを実行してくれない。悩んだあげくバグだということが判明。</p>
<p><span id="more-459"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> TableA <span style="color: #000000; font-weight: bold;">extends</span> Zend_Db_Table_Abstract 
<span style="color: #009900;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_schema</span>          <span style="color: #339933;">=</span> <span style="color: #0000ff;">'schema1'</span><span style="color: #339933;">;</span> 
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_name</span>            <span style="color: #339933;">=</span> <span style="color: #0000ff;">'tablea'</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span> 
<span style="color: #000000; font-weight: bold;">class</span> TableB <span style="color: #000000; font-weight: bold;">extends</span> Zend_Db_Table_Abstract 
<span style="color: #009900;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_schema</span>          <span style="color: #339933;">=</span> <span style="color: #0000ff;">'schema2'</span><span style="color: #339933;">;</span> 
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_name</span>            <span style="color: #339933;">=</span> <span style="color: #0000ff;">'tableb'</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>このバグは1.7.3で修正されたようです。<br />
こら～～　時間返せ～～；</p>
]]></content:encoded>
			<wfw:commentRss>http://wp.foliz.net/archives/459/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend_Db_Tableを使って新しい行を書き込み</title>
		<link>http://wp.foliz.net/archives/116</link>
		<comments>http://wp.foliz.net/archives/116#comments</comments>
		<pubDate>Wed, 29 Apr 2009 10:29:54 +0000</pubDate>
		<dc:creator>Fou</dc:creator>
				<category><![CDATA[ZendFramework]]></category>
		<category><![CDATA[Zend_Db_Table]]></category>

		<guid isPermaLink="false">http://wp.foliz.net/?p=116</guid>
		<description><![CDATA[Zend_Db_Tableを使って新しいフィールドを追加するときcreateRow()メソッドを使ってsave()する方法と単純にinsert()する二つの方法があります。 それぞれの使い方は $table = new  [...]]]></description>
			<content:encoded><![CDATA[<p>Zend_Db_Tableを使って新しいフィールドを追加するとき<code>createRow()</code>メソッドを使って<code>save()</code>する方法と単純に<code>insert()</code>する二つの方法があります。<br />
<span id="more-116"></span><br />
それぞれの使い方は</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Table<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newRow</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$table</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createRow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newRow</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'hoge'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newRow</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">udate</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Db_Expr<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'now()'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$newRow</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$table</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Table<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
  <span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'hoge'</span><span style="color: #339933;">,</span>
  <span style="color: #0000ff;">'udate'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Db_Expr<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'now()'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$table</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">insert</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>createRow()を使った書き方は更新作業などと同じ方法なので、登録も更新も同じルーチンで組みたいときなどに便利かもしれませんが、ほとんどの場合は別々に組んでいるのではないかと思うのでこれは抜いて考える。</p>
<p>実際使ってみるとそれぞれ微妙な特徴があって<br />
createRow()経由は<br />
$nowRowにたいして、存在しないフィールドを入れてもエラーにならない。<br />
Zend_Formと組み合わせた場合など、inputボタン属性がくっついてきてもそのまま使えるのが便利。<br />
ただし、DBのデフォルト設定を上書きしてしまうので、注意する必要があり。</p>
<p>insert()は<br />
存在しないフィールドを指定するとエラーになる。<br />
なのでZend_Formと組み合わせた場合など、inputボタン属性をunsetして使っている（他にいい方法があったら教えてｗ）。</p>
<p>結局どちらを優先して使おうか、非常に悩む。。<br />
結論が出ないが、ケースバイケースになるのかな・・？</p>
]]></content:encoded>
			<wfw:commentRss>http://wp.foliz.net/archives/116/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

