protected function _findRowset(Bbx_Model $parentModel) { $select = isset($this->_select) && !empty($this->_select) ? $this->_select() : $this->_model()->getTable()->select(); $this->_parentRelationship = Bbx_Model_Registry::get('Relationships')->getRelationshipDataFor($this->_parentModelName, $this->_throughName); $parentType = reset(array_keys($this->_parentRelationship)); $parentAttributes = $this->_parentRelationship[$parentType]; $relationshipType = 'Bbx_Model_Relationship_' . ucwords($parentType); if (array_key_exists('through', $parentAttributes)) { $relationshipType .= 'Through'; } $select->from($this->_childTableName); $select = call_user_func_array(array($relationshipType, 'getExternalConditions'), array($select, $parentModel, $this->_throughName, $parentAttributes)); $this->_throughRelationship = Bbx_Model_Registry::get('Relationships')->getRelationshipDataFor($this->_throughModelName, $this->_childName); $throughType = reset(array_keys($this->_throughRelationship)); $throughAttributes = $this->_throughRelationship[$throughType]; $throughRelationshipType = 'Bbx_Model_Relationship_' . ucwords($throughType); if ($throughType == 'belongsTo') { $this->_childName = Inflector::singularize($this->_childName); } $select = call_user_func_array(array($throughRelationshipType, 'getExternalConditions'), array($select, $this->_throughModel, $this->_childName, $throughAttributes)); $stmt = $select->query(); $config = array('table' => $this->_model()->getTable(), 'data' => $stmt->fetchAll(Zend_Db::FETCH_ASSOC), 'readOnly' => false, 'stored' => true); return new Bbx_Db_Table_Rowset($config); }
public function __destruct() { try { Bbx_Model_Registry::get('Relationships')->destroyRelationshipDataFor($this); Bbx_Model_Registry::get('Validations')->destroyDataFor(get_class($this)); Bbx_Model_Registry::get('Adaptors')->destroyDataFor(get_class($this)); } catch (Exception $e) { } unset($this->_iterator); unset($this->_table); unset($this->_rowData); unset($this->_validations); unset($this->_oldData); }