title: Doctrine: Counting an entity's items with a condition
body: <p>How can I count an entity's items with a condition in Doctrine? For example, I realize that I can use:</p>
  
  <pre><code>$usersCount = $dm-&gt;getRepository('User')-&gt;count();
  </code></pre>
  
  <p>But that will only count all users. I would like to count only those that have type employee. I could do something like:</p>
  
  <pre><code>$users = $dm-&gt;getRepository('User')-&gt;findBy(array('type' =&gt; 'employee'));
  $users = count($users);
  </code></pre>
  
  <p>That works but it's not optimal. Is there something like the following:? </p>
  
  <pre><code>$usersCount = $dm-&gt;getRepository('User')-&gt;count()-&gt;where('type', 'employee');
  </code></pre>