title: Doctrine count records of table
body: <p>I would like to know how I can count all records of an entity in a doctrine repository</p>
  
  <p>I found this solution but am not sure if this is good so:</p>
  
  <pre class="lang-php prettyprint-override"><code>public function findAllCounted()
  {
      return $this-&gt;getEntityManager()
          -&gt;createQuery('SELECT COUNT(a.id) FROM KSRArticleBundle:Article a')
          -&gt;getSingleScalarResult();
  }
  </code></pre>
  
  <p>Best Regards,
  Bodo</p>