/** * Changes table name for object relations class * * If the second parameter is default to false, the first is the * table name. Otherwise the two parameters are a pair of base * classes for a relationship. * * @param string $table_or_base_a * @param string $base_b * @return void */ protected function _setRelationTable($table_or_base_a, $base_b = false) { // get relation table name (w/o prefix) $table = $table_or_base_a; if ($base_b) { $table = $this->getRelationTable($table_or_base_a, $base_b); } // fix bug 175: make DSN always the same as class_a or class_b if ($base_b) { // set dsn to relation table $this->cm_obj_rel->setDsn($this->_getRelationDsn($table_or_base_a, $base_b)); // remove cached db for relation table if (isset($this->dbs[$this->cm_obj_rel->getName()])) { unset($this->dbs[$this->cm_obj_rel->getName()]); } } // set table name for relationship $this->cm_obj_rel->setTable($table); }
/** * Overrides {@link epManagerBase::initialize()} * @param bool $force whether to force initialization * @return bool * @throws epExceptionManager */ protected function initialize($force = false) { // call parent epManagerBase to initialize $status = parent::initialize($force); // check if init'ed before if (!$force && $this->cm_obj_rel) { return true; } // check if epObjectRelation has been compiled include_once EP_SRC_ORM . '/epObjectRelation.php'; if (!($this->cm_obj_rel =& $this->_getMap('epObjectRelation'))) { if (!($this->cm_obj_rel =& $this->_compileClass('epObjectRelation'))) { throw new epExceptionManager('Failed in compiling class epObjectRelation'); return false; } } // append overall table prefix $this->rel_tbl_prefix = $this->getConfigOption('relation_table'); if ($prefix = $this->getConfigOption('table_prefix')) { $this->rel_tbl_prefix = epUnquote($prefix) . $this->rel_tbl_prefix; } // set relation table name $this->cm_obj_rel->setTable($this->rel_tbl_prefix); // set default dsn to relation table $this->cm_obj_rel->setDsn($this->getConfigOption('default_dsn')); // cache relation table splitting flag $this->rel_tbl_split = $this->getConfigOption('split_relation_table'); return $status; }