sql - Join with conditional IN with Doctrine2 -
not sure possible, looks should
in video
entity, i've got manytoone associate product
entity
here, trying acquire published products, , acquire videos belong product join
// productrepository.php public function findpublished() { $q = $this->getentitymanager()->createquerybuilder(); $q->select(['p', 'v'])->from($this->getentityname(), 'p') ->leftjoin('p.videos', 'v', 'on', 'p in v.products') ->where('p.published = :published') ->setparameter('published', true); $results = $q->getquery()->getresult(); return $results; }
the exception comes this:
[syntax error] line 0, col 76: error: expected end of string, got 'on' [1/2] queryexception: select p, v company\corebundle\entity\product p left join p.videos v on p in v.products p.published = :published
if entities mapped correctly, don't need specify join condition. try this
$q->select(['p', 'v'])->from($this->getentityname(), 'p') ->leftjoin('p.videos', 'v') ->where('p.published = :published') ->setparameter('published', true);
Comments
Post a Comment