symfony - JOIN WITH entity.collection Doctrine 2 -
i've been trying lot of different things can't seem find way join... entity's attribute collection. have users , contacts. because of reasons, want make query such :
select c bundle:contact c left join bundle:user u c.user = u c in u.contacts
i know query doesn't seem make sense, actual query i'm working on :)
so doctrine not accept query expects select...from after in. how make query can check c belongs collection u.contacts? how 1 restrain selection according select in entity's attribute?
ok, honest, have no idea trying do. give 2 examples, 1 need or @ least give idea do.
first problem; , in conditions doesn't make sense me. if want join users, should this:
//contactrepository public function findmesomething() { $subquery = "select s1.id bundle:user s1 ... condition" ; return $this->createquerybuilder("c") ->leftjoin("c.users", "u", "with", "u.id in ($subquery)" ...
this join contact users; not all, users limited $subquery.
second: if want limit fetching contacts (primary select),
$subquery = "select s1.id bundle:contact s1 ... condition" ; ->where("c.id in ($subquery)"
Comments
Post a Comment