title: Complex SQL query into Zend
body: <p>I am trying to build a social network using Zend Framework. However, recently I have difficulty in making some complex SQL queries into Zend language. For example:</p>
  
  <pre><code>"SELECT t.plural_name, p.name as users_name, u.ID 
  FROM users u, profile p, relationships r, relationship_types t 
  WHERE t.ID=r.type 
        AND r.accepted=1 
        AND (r.usera={$user} OR r.userb={$user}) 
        AND IF( r.usera={$user},u.ID=r.userb,u.ID=r.usera) 
        AND p.user_id=u.ID"
  </code></pre>
  
  <p>How could I execute this query using Zend's select() object? Thank you very much!</p>