many2many中间表其他字段如何读取

有一个 many2mnay的结构 中间表 还有一个描述字段,但是 不知道在yii框架中如何把它读出来?

你需要为中间表定义一个AR。不然就只有通过DAO来读取了。

我的是一个比较笨的方法,比如

News(id, title),

Tags(id, title),

NewsTags(news_id, tags_id, status)

News中




"tags"=>array(self::HAS_MANY, "NewsTags", "news_id");



Tags中




"news"=>array(self::HAS_MANY, "NewsTags", "tags_id");



不知道有没有其它更好的方法呢~