title: Complex WHERE clause with Zend_Db using multiple AND OR operators
body: <p>I want to generate this complex WHERE clause in Zend_Db:</p>
  
  <pre><code>SELECT * 
  FROM 'products' 
  WHERE 
      status = 'active' 
      AND 
      (
          attribute = 'one' 
          OR 
          attribute = 'two' 
          OR 
          [...]
      )
  ;
  </code></pre>
  
  <p>I've tried this:</p>
  
  <pre><code>$select-&gt;from('product');
  $select-&gt;where('status = ?', $status);
  $select-&gt;where('attribute = ?', $a1);
  $select-&gt;orWhere('attribute = ?', $a2);
  </code></pre>
  
  <p>and that produced: </p>
  
  <pre><code>SELECT `product`.* 
  FROM `product` 
  WHERE 
      (status = 'active') 
      AND 
      (attribute = 'one') 
      OR 
      (attribute = 'two')
  ;
  </code></pre>
  
  <p>I did figure out one method of making this work but I felt it was sort of 'cheating' by using PHP to combine the "OR" clauses first and then combine them using Zend_Db where() clause.  PHP code:</p>
  
  <pre><code>$WHERE = array();
  foreach($attributes as $a):
      #WHERE[] = "attribute = '" . $a . "'";
  endforeach;
  $WHERE = implode(' OR ', $WHERE);
  
  $select-&gt;from('product');
  $select-&gt;where('status = ?', $status);
  $select-&gt;where($WHERE);
  </code></pre>
  
  <p>That produced what I was looking for.   But I'm curious if there's an "official" way of getting that complex WHERE statement (which really isn't too complex, just adding some parenthesis) with using the Zend_Db tool, instead of combining it in PHP first.</p>
  
  <p>Cheers!</p>