public function relations() { return array( 'category' => array(self::BELONGS_TO, 'Category', 'category_id'), 'widgets'=>array(self::MANY_MANY, 'TemplateWidget', 'templates_blocks_widgets_relations('.self::getPkAttr().', '.TemplateWidget::getPkAttr().')'), ); }