我有一个表infoContent存储一篇文章,现在我要建立一个多对多的关系表示与该篇文章有关的其他文章,如infoRelated:
±-------±----------+
| infoId | relatedId |
±-------±----------+
| 2 | 3 |
±-------±----------+
在infoContent的model里我是这么表示关系的:
public function relations()
{
return array(
'related'=>array(self::MANY_MANY, 'infoContent', 'infoRelated(infoId, relatedId)',
'together'=>true,
'joinType'=>'INNER JOIN',),
);
}
但我使用infoContent::model()->with(‘related’)->findbyPk(4);却返回空。
是否不能建立自己与自己的关联?
另外,有什么方法可以查看使用infoContent::model()这样的形式产生的sql吗?谢谢