Let’s suppose i have the following piece of code:
$qb = $this->em->createQueryBuilder();
$qb->add('select', 'a')
->add('from', 'Entities\Patientprofile a')
->add('where', 'a.userid=?1')
->setParameter(1, $patientId);
;
$query = $qb->getQuery();
$patientProfile = $query->getResult(3);
Doctrine adds “u” prefix to all of the results entities as stated here,which is undesirable.
Is there any native doctrine methods/solutions to remove these placeholders from results?
It doesn’t appear in your code, but I’m guessing you’re using getScalarResult() to execute your query. In my experience, Doctrine only affixes the alias prefix when you are using scalar hydration to return your results, as explained here. If you use one of the object hydration methods, the prefix should go away. Doctrine’s object hydration methods are getResult(), getSingleResult(), and getArrayResult().
Which hydration mode are you using, and does switching it to one of the above methods solve your problem?