You need to make $group
as array in order to utilize IN()
clause
$group = array('3','4','1');
$activePosts = $dm->createQuery('
SELECT COUNT(p.id)
FROM AcmeBundle:Posts p
WHERE p.userId IN (:user)
AND mb.open = :active'
)->setParameters(array(
'user' => $group,
'active' => '1'
));
This is will result in WHERE p.userId IN ('3','4','1')
and your current query is using it like WHERE p.userId IN ('3,4,1')
which is wrong and it is searching for a string 3,4,1
not for individual ids