简体   繁体   中英

CakePHP 2 .10.0 “OR” condition is not working

I am using Cakephp 2.10.0. While working with find condition, I am facing a strange issues LIKE "OR" condition convert automatically to "AND" eg

I am making find condition like:

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

It results

SELECT `LeadCall`.`id`, `LeadCall`.`lead_id` FROM `zindagihomes`.`lead_calls` AS `LeadCall` WHERE `LeadCall`.`future_call` != '11/19/2017' AND `LeadCall`.`future_call` != ''

And I want query something like this

SELECT `LeadCall`.`id`, `LeadCall`.`lead_id` FROM `zindagihomes`.`lead_calls` AS `LeadCall` WHERE `LeadCall`.`future_call` != '11/19/2017' OR `LeadCall`.`future_call` != ''

I got my mistake. It was due wrong array formation.

<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>

it is working fine as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM