0
我想在if條件中添加一個連接到我的查詢中,但它返回一個錯誤。 我們如何在教條中做到這一點? 有沒有像這樣的: $ qb-> andWhere('p。$ gender =:g') - > setParameter('g',$ gender); 加入主義symfony?如何在教條中通過qb連接連接?
$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": { "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": [ {
謝謝,現在一切都好了! – vahid