title: Multiple/nested "select where" with Zend_Db_Select
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1179279/grouping-where-clauses-with-zend-db-table-abstract">Grouping WHERE clauses with Zend_Db_Table_Abstract</a>  </p>
  </blockquote>
  
  
  
  <p>I need to create something like this:</p>
  
  <pre><code>select name from table where active = 1 AND (name LIKE 'bla' OR description LIKE 'bla')
  </code></pre>
  
  <p>The first part is easy:</p>
  
  <pre><code>$sqlcmd = $db-&gt;select()
  -&gt;from("table", "name")
  -&gt;where("active = ?", 1)
  </code></pre>
  
  <p>Now comes the tricky part. How can I nest? I know that I can just write </p>
  
  <pre><code>-&gt;orWhere("name LIKE ? OR description LIKE ?", "bla")
  </code></pre>
  
  <p>But thats wron, because I need to dynamically change all the parts. The query will be built all the time the script runs. Some parts get deleted, some altered. In this example I need to add those OR-s because sometimes I need to search wider.
  <strong>"My Zend Logic"</strong> tells me that the correct way is like this:</p>
  
  <pre><code>$sqlcmd = $db-&gt;select()
  -&gt;from("table", "name")
  -&gt;where("active = ?", 1)
  -&gt;where(array(
      $db-&gt;select-&gt;where("name LIKE ?", "bla"),
      $db-&gt;select-&gt;orWhere("description LIKE ?", "bla")
  ))
  </code></pre>
  
  <p>But that doesn't work (atleast I dont remember it working).</p>
  
  <p><strong>Please</strong>. Can someone help me to find a object oriented way for nesting <strong>"where"</strong>-s</p>