Hi. I have 2 tables (page and tags), and one related table page_tags. I want save data on table page_tags. But data doesn’t save.
Thank’s)
$genreIds = array(1, 2);
$page = Page::model()->findByPk(16);
$tags = Tags::model()->findAllByPk($genreIds);
$page->tags = $tags;
$page->save();
model Page
public function relations()
{
return array(
'tags' => array(self::MANY_MANY, 'Tags', 'page_tags(page_id, tag_id)'),
);
}
model Tags
public function relations()
{
return array(
'tags' => array(self::MANY_MANY, 'Page', 'page_tags(tag_id, page_id)'),
);
}