Zend_Db_Table使用時にID列だけを抜き出す。

表題のようなこと、Zend_Db_Table_Abstractを継承したテーブルクラスを使って、テーブルのサロゲートキー(や、他の列1つ)を抜き出す時には、どのような解がよいのでしょうか。私は愚直にSQLで

[php]
class Hoges extends Zend_Db_Table_Abstract
{
protected $_name = "Hoges";

/**
* IDのリストを返します。
*
* @return array id_list
*/
public function getIdList()
{
$sql = "SELECT id FROM " . $this->_name;
$result = $this->_db->fetchCol($sql);
return $result;
}
}
[/php]

などとしてしまいます。もう少しスマートなやり方もあるかと思うのですが。
皆様はどうでしょうか。

関連する記事:

Powered by

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">