Friday, March 29, 2013

Problem with nested AND / OR Condition

Hey Folks

maybe I'm just at a loss, but how do I create a SQL command like this with cakePHP?

SELECT *
FROM table
WHERE id = 1 OR (column1='test1' AND id=2) OR (column1='test2' AND id=3)


Please do not ask about the meaning, I have simplified a more complex command to make the problem clear.

The Condition would have to actually something like this:


$options = array(
'conditions' => array(
'OR' => array(
'id' => 1,
'AND' => array(
'column1' => 'test1',
'id' => 2
),
'AND' => array(
'column1' => 'test2',
'id' => 3
)
)
)
);

But the second 'AND' overrwrites the first one.

Can someone give me a hint? I would be grateful! ;-)

Greetings!
Carsten

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: