0
votes

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" e.g

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` != ''
1
Please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. - halfer

1 Answers

0
votes

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.