/** * * Fetches eager results into an existing native array rowset. * * @param Solar_Sql_Model_Params_Eager $eager The eager params. * * @param array &$array The existing native result row. * * @param Solar_Sql_Model_Params_Fetch $fetch The native fetch settings. * * @return void * */ protected function _fetchIntoArrayAll($eager, &$array, $fetch) { $col = "{$eager['alias']}.{$this->foreign_col}"; $use_select = $eager['native_by'] == 'select' || count($array) > $eager['wherein_max']; $join = null; $where = null; if ($use_select) { $join = $this->_getNativeBySelect($eager, $fetch, $col); $join['cond'] = array_merge((array) $join['cond'], $this->getForeignConditions($eager['alias'])); } else { $where = array_merge($this->_getNativeByWherein($eager, $array, $col), $this->getForeignConditions($eager['alias'])); } $params = array('alias' => $eager['alias'], 'cols' => $eager['cols'], 'join' => $join, 'where' => $where, 'order' => $this->order, 'eager' => $eager['eager']); $data = $this->_foreign_model->fetchAllAsArray($params); $data = $this->_collate($data, $this->foreign_col); // now we have all the foreign rows for all-of-all of the native rows. // next is to tie each of those foreign sets to the appropriate // native result rows. foreach ($array as &$row) { $key = $row[$this->native_col]; if (!empty($data[$key])) { $row[$this->name] = $data[$key]; } else { $row[$this->name] = $this->_getEmpty(); } } }