Reputation: 791
I need a basic "or" in my if else condition in php cake.
$oTourRecords = $this->Record->find('all', array(
'conditions' => array(
'record.builder_name' => 'rey',
'or' => array(
'record.builder_name' => 'norbert',
)
)
)
);
basically i need to get if the record contain builder_name = rey or "norbert" this one returns null.
Upvotes: 2
Views: 244
Reputation: 2795
You can also use
IN
to retrieve similar type of Data instead ofOR
conditions.
Example :
$oTourRecords = $this->Record->find('all', array(
'conditions' => array(
'record.builder_name IN'=>array(
'rey',
'norbert'
)
)
)
);
Upvotes: 1
Reputation: 8618
You can do it in several ways:
$oTourRecords = $this->Record->findAllByBuilderNameOrBuilderName('rey', 'norbert');
$oTourRecords = $this->Record->find('all', array(
'conditions' => array(
'OR' => array(
'record.builder_name' => 'norbert',
'record.builder_name' => 'rey',
)
)
));
$oTourRecords = $this->Record->find('all', array(
'conditions' => array('record.builder_name IN ' => array('norbert','rey'))
));
Upvotes: 2
Reputation: 1913
Try
$oTourRecords = $this->Record->find('all', array(
'conditions' => array(
'OR' => array(
'record.builder_name' => 'norbert',
'record.builder_name' => 'rey',
)
)
));
Upvotes: 4