用户有很多User_Questionaries。我想要具有特定问卷的分页用户。我使用了以下分页。
$paginate = array(
'conditions' => array(
'User.role' => IWOA,
'UserQuestionary.questionary_id' => $id
),
'recursive' => 1,
'limit' => 10,
'order' => array(
'name' => 'asc'
),
'contain' => array('UserQuestionary')
);
但它不是创建连接查询。它显示Unknown column UserQuestionary.questionary_id' in 'where clause'
问题是什么?我该怎么做?
答案 0 :(得分:0)
最后,我使用了连接查询来执行此操作。
$paginate = array(
'conditions' => array(
'Iwoa.role' => IWOA,
),
'joins' => array(
array(
'alias' => 'UserQuestionary',
'table' => 'user_questionaries',
'type' => 'LEFT',
'conditions' => 'UserQuestionary.user_id = Iwoa.id AND UserQuestionary.questionary_id = ' . $id
)
),
'limit' => 10,
'order' => array(
'name' => 'asc'
),
);