我需要帮助在CakePHP中运行此查询,我无法阅读文档。查询必须匹配此查询
SELECT
form_number,
code_b,
local_governments.lga,
local_governments.code,
concat(local_governments.code,code_b)
FROM
`applicants`
left join local_governments
on applicants.local_government_id=local_governments.id
where
printed=0
答案 0 :(得分:0)
我将假设您的模型设置正确并且也正确关联。
$applicants = $this->Applicant->find('all',
array(
'conditions' => array(
'Applicant.printed' => 0,
),
'contain' => array('LocalGovernment'),
'fields' => array(
'Applicant.form_number',
'Applicant.code_b',
'LocalGovernment.lga',
'LocalGovernment.code',
)
)
);
至于你的联合...只是在视图中显示值时这样做。
我希望这有帮助......让我知道。