title: Doctrine query : confusing addWhere, andWhere, orWhere
body: <p>I have a query :</p>
  
  <pre><code>$q-&gt;andWhere($q-&gt;getRootAlias().'.is_published = ?', 1);
  $q-&gt;andWhere($q-&gt;getRootAlias().'.published_at &gt;= ?', time());
  $q-&gt;leftJoin($q-&gt;getRootAlias().'.EventLdapGroup l');
  $q-&gt;andWhereIn('l.ldap_group_id', $permissions_id );
  $q-&gt;orWhere('l.ldap_group_id IS NULL);
  </code></pre>
  
  <p>which outputs : </p>
  
  <pre><code>FROM 
      Event r LEFT JOIN r.EventLdapGroup l 
  WHERE 
      r.is_published = ? AND 
      r.published_at &gt;= ? AND 
      l.ldap_group_id IN (?, ?) OR 
      l.ldap_group_id IS NULL
  </code></pre>
  
  <p>The only problem is that if <code>ldap_group_id</code> is null (the last condition) it'll remove the <code>is_published</code> and <code>published_at</code> conditions.</p>
  
  <p>I want something like that [either the values are in ldap_group_id, or either it's null] :</p>
  
  <pre><code>FROM 
      Event r LEFT JOIN r.EventLdapGroup l 
  WHERE 
      r.is_published = ? AND 
      r.published_at &gt;= ? AND 
      (l.ldap_group_id IN (?, ?) OR l.ldap_group_id IS NULL)
  </code></pre>
  
  <p>And i must say that i'm lost with the complex where condition.
  How to achieve that ?</p>
  
  <p>Thanks </p>