What you have written in the question is attempting to do, more or less, this (for illustration, not the actual query generated):
WHERE id = 1 AND (column = 'test1' AND id = 2) AND (column = 'test2' AND id = 3)
^ ^ // From where AND is written in the question
^ ^ // ImplicitJust remove the AND keys:
$options = array(
'conditions' => array(
'OR' => array(
'id' => 1,
array(
'column1' => 'test1',
'id' => 2
),
array(
'column1' => 'test2',
'id' => 3
)
)
)
);
'conditions' => array(
'OR' => array(
'id' => 1,
array(
'column1' => 'test1',
'id' => 2
),
array(
'column1' => 'test2',
'id' => 3
)
)
)
);
Which will generate:
WHERE id = 1 OR (column = 'test1' AND id = 2) OR (column = 'test2' AND id = 3)
AD
On Saturday, 30 March 2013 03:02:02 UTC+1, Carsten Wawer wrote:
On Saturday, 30 March 2013 03:02:02 UTC+1, Carsten Wawer wrote:
Hey Folksmaybe 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:
Post a Comment