Reputation: 411
I have this query below:
SELECT *
FROM mydb.users
left join mydb.jobs
on users.user_id = jobs.job_id;
And I used to convert them in orm query just like below:
return
$qb = $this->entityManager->createQueryBuilder();
$qb->select('rb', 'l')
->from('Admin\Entity\Users', 'rb')
->leftJoin(
'Admin\Entity\Jobs',
'l',
\Doctrine\ORM\Query\Expr\Join::WITH,
'rb.user_id = l.job_id'
)
->getQuery()
->getResult(AbstractQuery::HYDRATE_ARRAY);
But it doesn's still work. I get the following error:
PHP Fatal error: Call to a member function createQueryBuilder() on null
please help i don't know what to do.
Upvotes: 0
Views: 407
Reputation: 44356
Well it simply means you don't have an EntityManager
instance in $this->entityManager
.
My guess would be that $this->entityManager
is probably null because you did not inject an EntityManager
inside your class instance.
Upvotes: 1
Reputation: 273
Try this
$entityManager = $this->serviceLocator->get('Doctrine\ORM\EntityManager');
$qb = $entityManager->createQueryBuilder();
Or make sure $this->entityManager is assigned.
Upvotes: 1