I want to get the last user profile . But i am not able to do that in DQL.
I have this code
$em = $this->getEntityManager();
$dql = "SELECT p FROM AcmeBundle:UserProfile p
WHERE p.user_id = :user_id
ORDER BY p.createdAt DESC ";
$allProfiles = $em->createQuery($dql)
->setParameter('user_id', $user_id)
->setMaxResults(5)
->getResult();
return $allProfiles;
It returns all the profiles.
If i use getSingleResult() then it says result not unique
1 Answer