New to Doctrine and trying to convert the MySQL query below to queryBuilder.
SELECT COUNT(t2.user_id) FROM(
SELECT t2.* FROM logins t2
WHERE t2.login_time >= DATE_SUB(NOW(),INTERVAL 5 HOUR)
LIMIT 10
) t2
WHERE t2.is_success = 1
I've seen a few examples of subquery on the WHERE
clause here on SO and attempted to adapt it as per below, but that does not really work.
$sub = $this->createQueryBuilder('l')
->select('l')
->where('l.loginTime >= :date
and l.userId = :user_id')
->setParameters( $parameters )
->getDQL();
$qb = $this->createQueryBuilder('a')
->select('count(a.id)')
->from( $sub, 'a' )
->where('a.isSuccess = 0');
return $qb->getQuery()->getSingleScalarResult();
Thanks