Question: I would like to know how I can count all records of an entity in a doctrine repository

I found this solution but am not sure if this is good so:

```php
public function findAllCounted()
{
    return $this->getEntityManager()
        ->createQuery('SELECT COUNT(a.id) FROM KSRArticleBundle:Article a')
        ->getSingleScalarResult();
}

```

Best Regards,
Bodo

Answer: 
You don't need to count on a specific field, so this will do:

```
SELECT COUNT(a) FROM KSRArticleBundle:Article a

```
Just for the record, it is usually better to count on the id :

```
SELECT COUNT(a.id) FROM KSRArticleBundle:Article a

```

is a little better