我有使用cakephp3的问题,我有3个表用户(user_id,用户名,密码,电子邮件),帖子(post_id,user_id,content_post)和评论(comment_id,user_id,post_id)我如何使用查询加入3表cakePHp3谢谢你。
答案 0 :(得分:0)
检查示例查询,
$GroupAccountIds = $this->ClientForm->find(
'list',
[
'joins' => [
[
'table'=>'group_accounts',
'alias' => 'GroupAccount',
'type' => 'INNER',
'conditions' => [
'ClientForm.created_group_account_id = GroupAccount.group_account_id',
'ClientForm.deleted IS NULL'
]
],
],
'conditions' => [
'GroupAccount.group_account_category_id' => $smsfCategoryId,
'GroupAccount.deleted' => null,
],
'fields' => [
'ClientForm.created_group_account_id',
'ClientForm.created_group_account_id',
],
]
);