1)topic_tag_map。 列:ID,topic_id,TAG_ID,VERSION_NAME
2)標籤 列:ID和TAG_NAME
外鍵是TAG_ID和id
對於這兩個我創建模型中的表和定義的關係是這樣的:
在topic_tag_map
'topic' => array(self::BELONGS_TO, 'Topic', 'topic_id'),
'tagging' => array(self::BELONGS_TO, 'Tagging', 'tag_id'),
這裏我只想獲取從標籤表的TAG_NAME。 所以,我想這一點:
$tags = TopicTagMap::model()->with(array(
'tagging'=>array(
'select' => 'tagging.tag_name',
'joinType'=>'INNER JOIN',
'condition' => 'topic_id = '.$topic->id.' and version_name = 1',
),
))->findAll();
但它給所有列。
之後,我想這也:
$tags = TopicTagMap::model()->findAll(array(
'select' => 'tagging.tag_name',
'condition' => 'topic_id = '.$topic->id.' and version_name = 1',
'with' => 'tagging',
));
但是這投擲的錯誤: 無效的列名
PLZ人幫助是嚴重的問題 – RahulG 2014-11-24 13:54:49