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