mysql - Symfony2 sublevel query -
i'm trying list of flights search form. user picks city, number of passengers, , query returns available flights.
i tried 1 :
public function findsearch($city, $nbpax) { $qb = $this->createquerybuilder('a'); $qb->where('a.precisedate >= :now') ->setparameter('now', new \datetime()) ->andwhere('a.available > :min') ->setparameter('min', $nbpax) ->andwhere('a.departure > :min') ->setparameter('min', $nbpax) ->andwhere('a.departure.city = :city') ->setparameter('city', $city) ->orderby('a.precisedate', 'asc') ; return $qb ->getquery() ->getresult() ; }
but seems a.departure.city not recognised valid comparison (departure airport, linked city onetomany relationship)
how can change query can access airport city ?
you join on departure prior comparisons, so:
$qb->join('a.departure', 'd')
and instead of a.departure
you'd d
, e.g.
->andwhere('d.city = :city')
the part don't understand a.departure > :min
clause, field on departure entity comparing against? or departure field? in case a.departure.city = :city
doesn't make sense.
regardless, dql documentation on joins source of reference.
Comments
Post a Comment