I have a query like this;
$builder = $this->createQueryBuilder("p")
->where("p.published = :published AND p.mission.game_system = :game_system")
->orderBy("p.date_published", "DESC")
->setMaxResults($limit)
->setParameter("published", true)
->setParameter("game_system", $game_system);
p
is a project.
I want to only get projects for a specific game system, but the game system is stored in the mission. I cannot add the game system to the project as this creates a recursive reference.
How do I enable the where
to get projects for a specific game system only?
For example this would get all projects where the mission id is 1;
$builder = $this->createQueryBuilder("p")
->where("p.published = :published AND p.mission = :mission")
->orderBy("p.date_published", "DESC")
->setMaxResults($limit)
->setParameter("published", true)
->setParameter("mission", 1);
But I want all the projects that relate to the game system, which is stored inside of the mission row. The mission and game system have a manyToOne relationship.
For example I want all projects where the game system id is 5 regardless of the mission, something like this, but this fails
$builder = $this->createQueryBuilder("p")
->where("p.published = :published AND p.mission.game_system = :game_system")
->orderBy("p.date_published", "DESC")
->setMaxResults($limit)
->setParameter("published", true)
->setParameter("game_system", 5);