时间:2021-07-01 10:21:17 帮助过:19人阅读
public function relations() {
return array(
....
'userInfo' => array(self::BELOGNS_TO, 'User', 'user_id'),
);
}
'article' => array(self::HAS_ONE, 'Article', 'article_content_id'),
$result = ArticleContent::model() -> find('article_content_id = :aid', array(':aid' => $articleId));
prinr_r($result -> attributes); // 打印出来的都是article_content表的字段
print_r($result -> article -> attributes); //得到article表的字段
print_r($result -> article -> userInfo -> user_name); //得到username