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.

Accepted Answer

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

$select = $this->select()->where('id = 1')->where('title IN (?)', array('durr', 'hurr'));
Written by garvey
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki