I'm having troubles with a parameter in Symfony request. I have 3 entities : Mall hasMany Stores hasMany Turnovers
In my turnoverEntity, I need to get turnovers from one company. I did this :
public function findForCompany($companyId)
{
$qb = $this->createQueryBuilder('t')
->innerJoin('t.store', 's')
->innerJoin('s.mall', 'm')
->where('m.id = :companyId');
$qb->setParameter('companyId', $companyId);
dump($companyId);
dump($qb->getQuery()->getSql());
dump($qb->getQuery()->getResult());
exit();
return $qb->getQuery()->getResult();
}
When I dump sql I get
SELECT t0_.id AS id_0, t0_.amount AS amount_1, t0_.created_at AS created_at_2, t0_.month AS month_3, t0_.year AS year_4, t0_.is_consolidated AS is_consolidated_5, t0_.created_by AS created_by_6, t0_.store_id AS store_id_7, t0_.company_id AS company_id_8 FROM turnover t0_ INNER JOIN store s1_ ON t0_.store_id = s1_.id INNER JOIN mall m2_ ON s1_.mall_id = m2_.id WHERE m2_.id = ?
Notice the "?" at the end of the query. I get no result in my query. Did i miss something ?
EDIT :
Thanks to Kuba, the answer is just a miss in entities relationship The query should be :
$qb = $this->createQueryBuilder('t')
->innerJoin('t.store', 's')
->innerJoin('s.mall', 'm')
->where('m.company = :companyId');