Answer the question
In order to leave comments, you need to log in
Symfony3.3 Join via table. How to write using QueryBuilder.?
The Hotel has a city, the city has a state. You need to make a selection using querybuilder
return (object)$this->em->getConnection()
->createQueryBuilder()
->from(static::TABLE_NAME, 'v')
->innerJoin('v', static::CITY_TABLE, 'ci', 'ci.id = v.city_id')
->innerJoin('s', static::STATE_TABLE, 'st', 'ci.id = s.state_id')
->select('v.*, ci.name as city_name')
->where('v.code = :code')
->setMaxResults(1)
->setParameters([
'code' => $code,
])
->execute()
->fetch();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question