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