Possible duplicate:
Grouping WHERE clauses with Zend_Db_Table_Abstract
I need to create something like this:
select name from table where active = 1 AND (name LIKE 'bla' OR description LIKE 'bla')
The first part is simple:
$sqlcmd = $db->select() ->from("table", "name") ->where("active = ?", 1)
Now comes the hard part. How can I nest? I know that I can just write
->orWhere("name LIKE ? OR description LIKE ?", "bla")
But this is wron, because I need to dynamically change all parts. The request will be built all the time when the script is run. Some parts are deleted, some are changed. In this example, I need to add these OR-s, because sometimes I need to look for a wider one. "My Zend Logic" tells me that the correct way is:
$sqlcmd = $db->select() ->from("table", "name") ->where("active = ?", 1) ->where(array( $db->select->where("name LIKE ?", "bla"), $db->select->orWhere("description LIKE ?", "bla") ))
But this does not work (at least I do not remember that it worked).
Please . Can someone help me find an object oriented way to nest "where" -s
source share