我正在尝试在cakePHP 2.x中编写以下查询
SELECT u.username, s.code
FROM users u
LEFT JOIN skills_users su ON su.user_id = u.id
LEFT JOIN skills s ON s.id = su.skill_id
WHERE s.id =2
我不想使用$ this-Model-> query(“....”);
我尝试使用cakePHP Linkable行为(https://github.com/lorenzo/linkable),如同IRC中#cakephp的人员所建议的那样,但似乎我的情况被忽略了。
$user = $this->User->find('all', array(
'contain' => array(
'Skill',
),
'link' => array('Skill' => array('conditions' => array('Skill.id' => 2), 'type' => 'inner'))));
答案 0 :(得分:1)