0

请在 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
4

1 回答 1

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', 
        )
    )
);

至于你的 concat... 只是在视图中显示值时这样做。

我希望这会有所帮助......让我知道。

于 2012-09-17T18:31:52.710 回答