I am trying out doctrine using this tutorial. https://www.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/getting-started.html. The issue is, when passing the DQL statement to the Create Query method, I get the error below.
Fatal error: Uncaught Doctrine\ORM\Query\QueryException: SELECT b, e, r FROM Bug b JOIN b.engineer e JOIN b.reporter r ORDER BY b.created DESC in
Here are the code:
$dql = "SELECT b, e, r FROM Mimoh\Gtcsl\entity\Bug::class b JOIN b.engineer e JOIN
b.reporter r ORDER BY b.created DESC";
$query = $entityManager->createQuery($dql);
$query->setMaxResults(12);
$bugs = $query->getResult();
But when I when I specify the class name, the code works. Here is the working code.
use Mimoh\Gtcsl\entity\Bug;
$dql = "SELECT b, e, r FROM " . Bug::class . " b JOIN b.engineer e JOIN
b.reporter r ORDER BY b.created DESC";
and this also works:
$bug = Mimoh\Gtcsl\entity\Bug;
$dql = "SELECT b, e, r FROM $bug b JOIN b.engineer e JOIN
b.reporter r ORDER BY b.created DESC";
I kind of know these might not be the proper way. Please any help will be highly appreciated.