2

I was wondering how I can get something like this:

SELECT * from `table` WHERE id='1' AND (title='hurr' OR title='durr')

in Zend framework? To my knowledge there are only where() functions, which together make AND relationships and orWhere() which adds an OR rule, but if used together, a select like this:

$select=$this->select()->where("id='1'")->where("title='hurr'")->orWhere("title='durr'");

This would create a query like this

SELECT * from `table` WHERE id='1' AND title='hurr' OR title='durr'

Which is something completely different.

2 Answers 2

4
$select = $this->select()->where('id = 1')->where("title='durr' OR title='hurr'");

$select = $this->select()->where('id = 1')->where('title IN (?)', array('durr', 'hurr'));
Sign up to request clarification or add additional context in comments.

Comments

1

You can do something like

$select=$this->select()->where("id='1'")->where("title='hurr' OR title='durr'");

You can check the manual

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.