Zend_Db_Table_Abstract を正しく使用する方法を理解しようとしています。name
クエリから列だけを返したい。次のコードの何が問題なのか説明していただけますか?
class Model_DbTable_Foo extends Zend_Db_Table_Abstract
{
protected $_name = 'foo';
public function getFooById($id) {
$select = $this->select(true)->columns('name')->where('id=' . $id);
$row = $this->fetchRow($select);
print_r($row->toArray());
}
}
アップデート:
以下の @Joshua Smith の例から、select() を使用してこれを正しく行う方法を理解できました。
$select = $this->select()
->from($this->_name, 'name') // The 2nd param here could be an array.
->where('id = ?', $id);
$row = $this->fetchRow($select);
print_r($row->toArray());