I have two entities - BlacklistedUsers and UserAccounts. I am trying to build a DQL that allows me to join those two entities together and get BlacklistedUsers#id
, UserAccounts#name
and BlacklistedUsers#reason
.
My query builder code is
$qb = $this->createQueryBuilder('u')
->join(UserAccounts::class, 'a');
And regardless of how simple it is the following code still manages to fail
Fatal error: Uncaught exception 'Doctrine\ORM\Query\QueryException' with message 'SELECT u FROM Orm\Entity\BlacklistedUsers u INNER JOIN Orm\Entity\UserAccounts a ORDER BY u.reason asc' in ***
I double checked the generated query agains docs ( http://doctrine-orm.readthedocs.org/en/latest/reference/dql-doctrine-query-language.html ) and compared it to their example
<?php
$query = $em->createQuery('SELECT a FROM CmsArticle a JOIN a.user u ORDER BY u.name ASC');
$articles = $query->getResult(); // array of CmsArticle objects
I do not see any difference between the query they have and what my query builder generates.
Below is the class diagram to make things easier
Thanks for your help