我将如何向我的 relations() 函数添加第 3 个关系以将CommentsPosts
模型与store
模型连接起来。CommentsPosts.store_id = Store.id
和CommentsPosts.store_zip = Store.zip
在哪里?
在我的评论中.php
public function relations()
{
return array(
'user' => array(self::BELONGS_TO, $this->module->userModelClass, 'userId'),
'posts' => array(self::HAS_MANY, "CommentsPosts", array("commentId" => "id")),
'store'=>'',
);
}
评论帖子.php在modules/comments/model
和商店.php在modules/store/model
仅供参考,我正在使用 Yii 1.1.15
我不确定你的关系,但试试像波纹管这样的东西
在评论帖子中 模型 添加关系
public function relations()
{
return array(
'store' => array(self::HAS_MANY, "Store", array("store_id" => "id")),
);
}
检索时
$enity->post // give all post
$enity->post[i]->store // gives the each post data of store