- 使用dql进行联表查询
public function getChampionQuizzes($gameCategoryId) { $dql = "SELECT q FROM TronWebBundle:Quiz q LEFT JOIN q.league l WHERE q.league is not null AND l.gameCategory = :gameCategory"; $quiz = $this->getEntityManager() ->createQuery($dql) ->setParameter('gameCategory', $gameCategoryId) ->getResult(); return $quiz; }
2. 以数组方式传入参数
public function getAllQuizInfoByGames($games) { $dql = "SELECT qr FROM TronWebBundle:QuizResult qr WHERE qr.game In (:games)"; $allQuizInfo = $this->getEntityManager() ->createQuery($dql) ->setParameter('games', $games) ->getResult(); return $allQuizInfo; }