I'm trying to figure out how to use Zend_Db_Table_Abstract correctly. I want to return just the name
column from my query. Can you please explain what's wrong with the following code?
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());
}
}
Update:
From the example by @Joshua Smith below, I was able to figure out how to use select() to do this correctly:
$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());