/** * Переписываем стандартный _fetch с учётом выборки связанных данных * * @param Zend_Db_Table_Select $select */ protected function _fetch(Zend_Db_Table_Select $select) { if ($this->_route_id) { $select = $select->where('route_id = ?', $this->_route_id); } $rows = parent::_fetch($select); foreach ($rows as &$row) { foreach ($row as $fieldName => $field) { if (array_key_exists($this->_cleanName . '_' . $fieldName, self::$linkedFieldsTableData)) { if ($this->_isSerialized($row[$fieldName])) { $row[$fieldName] = $this->_unserialize($row[$fieldName]); if (sizeof($row[$fieldName])) { $field = implode(',', $row[$fieldName]); } } $data = explode(',', $field); foreach ($data as $val) { $val = chop($val); foreach (self::$linkedFieldsTableData[$this->_cleanName . '_' . $fieldName] as $linked_row) { if (is_array($linked_row) && $val == $linked_row['publication_id']) { if (false == array_key_exists($fieldName . '_linked', $row) || false == is_array($row[$fieldName . '_linked'])) { $row[$fieldName . '_linked'] = array(); } array_push($row[$fieldName . '_linked'], $linked_row); break; } } } } } $row['rubric_id'] = $row['pub_rubric_id'] = $this->_tableProfile[0]->rubric_id; } return $rows; }
/** * * @param Zend_Db_Table_Select $select * @return type */ protected function _fetch(Zend_Db_Table_Select $select) { if (in_array('deleted', $this->_getCols())) { $select->where($this->_name . '.deleted = 0'); } /* if ($this->getAutoRestrict()) { if (in_array($this->getAutoRestrict(), $this->_getCols())) { $identity = Zend_Auth::getInstance()->getIdentity(); if (isset($identity->empresa_id) && $identity->empresa_id) { $select->where($this->_name . '.' . $this->getAutoRestrict() .' = ?', $identity->empresa_id); } } } */ if ($this->getAutoJoin()) { $select = $this->addAutoJoin($select); } return parent::_fetch($select); }