How do I limit a query to specific columns while using Zend_Db_Table_Abstract?
(getDbTable() below returns a Zend_Db_Table_Abstract object)
$resultSet = $this->getDbTable()->fetchAll(
$this->getDbTable()->select()
->where('forgienKey = \'' . $forgienKey . '\'')
->order("'id' ASC")
);
I only need the id column returned but the entire row is returned. Thanks for any help!
As stated in the docs :
$select = $table->select();
$select->from($table, array('bug_id', 'bug_description'))
->where('bug_status = ?', 'NEW');
$rows = $table->fetchAll($select);
So, for you :
$resultSet = $this->getDbTable()->fetchAll(
$this->getDbTable()->select()
->from($this->getDbTable(), array('id'))
->where('forgienKey = \'' . $forgienKey . '\'')
->order("'id' ASC")
);
Please try this
$resultSet = $this->getDbTable()->fetchAll(
$this->getDbTable()->select()
->columns('id')
->where('forgienKey = \'' . $forgienKey . '\'')
->order("'id' ASC")
);
EDIT
Check the link