You may have already realized but:
The AND array key is not necessary.
If you define the same key twice in php - you overwrite the same value
I.e.
debug(array('AND' => array('Equipment.company_id' =>
$this->passedArgs['company'], 'Equipment.deleted' => 0,), 'OR' =>
array('Equipment.location_id' => null, 'Equipment.location_id' => -1,
'Equipment.location_id' => -2))));
Has nothing to OR - there's only one thing in that array.
>From the docs "By default, CakePHP joins multiple conditions with boolean
AND;" Therefore you don't actually need this:
'AND' => array( <-
So your final conditions should look like this:
array(
'Equipment.company_id' => $this->passedArgs['company'],
'Equipment.deleted' => 0,
'OR' => array(
array('Equipment.location_id' => null),
array('Equipment.location_id' => -1 ),
array('Equipment.location_id' => -2)
)
)
OR
array(
'Equipment.company_id' => $this->passedArgs['company'],
'Equipment.deleted' => 0,
'OR' => array(
array('Equipment.location_id' => null),
array('Equipment.location_id' => array(-1, -2) )
)
)
AD
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php