public function getWorksheetData($id) {
/** create the following query using select object:
SELECT wc.label, wd.notes FROM worksheet_data wd
LEFT JOIN worksheet_columns wc ON wd.column_id = wc.id;
*/
$id = (int) $id;
$select = $this->_db->select()
->from(array('wd'=>'worksheet_data'),
array('wc.label','wd.notes'))
->join(array('wc'=>'worksheet_columns','wd.column_id = wc.id'))
->where("wd.id = :worksheet_id");
$results = $this->_db->fetchAll($select, array('worksheet_id' => $id),Zend_Db::FETCH_ASSOC);
return array('results'=>$results);
}
Why does this query become:
SELECT wc
.label
, wd
.notes
, wc
.* FROM worksheet_data
AS wd
INNER JOIN worksheet_columns
AS wc
WHERE (wd.id = :worksheet_id)
and return wc.*?