我正在使用Cakephp 2.10.0。在使用查找条件时,我遇到一个奇怪的问题,如“OR”条件自动转换为“AND”,例如
我正在查找条件:
$this->{$this->leadCall}->find('list', array('conditions'=>array($this->leadCall.'.future_call !=' => date('m/d/Y'), 'or' => array($this->leadCall.'.future_call !=' => '')),'fields' => array('lead_id')));
结果
SELECT `LeadCall`.`id`, `LeadCall`.`lead_id` FROM `zindagihomes`.`lead_calls` AS `LeadCall` WHERE `LeadCall`.`future_call` != '11/19/2017' AND `LeadCall`.`future_call` != ''
我希望查询类似这样的内容
SELECT `LeadCall`.`id`, `LeadCall`.`lead_id` FROM `zindagihomes`.`lead_calls` AS `LeadCall` WHERE `LeadCall`.`future_call` != '11/19/2017' OR `LeadCall`.`future_call` != ''
答案 0 :(得分:0)
我弄错了。这是由于错误的阵列形成。
<pre>
$conditions = array(
'OR' => array(
$this->leadCall.'.future_call !=' => date('m/d/Y'),
$this->leadCall.'.future_call !=' => ''
)
);
$futureCall = $this->{$this->leadCall}->find('list', array('conditions'=>$conditions,'fields' => array('lead_id')));
</pre>
它正如预期的那样正常工作。