public function hasFkField() { $notManyToMany = $this->getRelationType() !== TActiveRecord::MANY_TO_MANY; return $notManyToMany && isset($this->_relation[2]) && !empty($this->_relation[2]); }