I want to add a join to my query in if condition but it returned an error. how we can do it in doctrine? is there any thing like: $qb->andWhere('p.$gender = :g')->setParameter('g', $gender); for join in doctrine symfony??
$qb->select("p")->from("PfmSanadBundle:Person", "p");
if ((isset($province) && trim($province) !== '') && (isset($City) && trim($City) !== '')){
$qb->join("p" ,"students", "ps")
->join("ps" ,"organization", "po")
->join("po" ,"cityProvince", "pc")
->join("pc" ,"province", "pp");
}
if ((isset($province) && trim($province) !== '') && !isset($City)) {
$qb->join("p.students", "ps")
->join("ps.organization", "po");
}
$res = $qb->getQuery()->getArrayResult();
error (postman):
"error": { "code": 500, "message": "Internal Server Error", "exception": [ { "message": "[Semantical Error] line 0, col 49 near 'p students INNER': Error: Class 'p' is not defined.", "class": "Doctrine\ORM\Query\QueryException", "trace": [ {