我需要像这样构造一个 cakePHP 模型查询:
SELECT `Translate`.`var_name` , IF( prove_cn_sim =1, lang_cn_sim, lang_en )
FROM 'translate` AS `Translate`
我试过了:
$this->find("list", array(
'fields' => array("var_name","IF(prove_cn_sim = 1, lang_cn_sim, lang_en)"),
));
但我得到了这样的东西:
SELECT `Translate`.`var_name`, Translate.IF(prove_cn_sim = 1, lang_cn_sim, lang_en) FROM `translate` AS `Translate`
CakePHP 为 IF 添加表前缀。你知道任何解决方案吗?