I'm trying to get the recent document from my database, I have created this queryBuilder
to get the Document obeject
but it seems not working good when I add the clause Having
.
This my query:
$qb = $this->createQueryBuilder('sm');
$qb
->andWhere('sm.supplier = :supplier')
->setParameter('supplier', $supplierId)
->andHaving('MAX(sm.createdAt)')
->groupBy('sm.id');
return $qb->getQuery()->getOneOrNullResult();
And this is the exception I'm getting:
{"code":500,"message":"[Syntax Error] line 0, col -1: Error: Expected =, <, <=, <>, >, >=, !=, got end of string."}
This my DQL
:
"SELECT sm FROM SupplierBundle\\Entity\\SupplierMedia sm WHERE sm.supplier = :supplier AND sm.type = :type GROUP BY sm.id HAVING MAX(sm.createdAt)"