sql - symfony doctrine: find objects where one of the one-to-many-associations is like value -


i have entity named "customer". @ entity there onetomany-association other entity "customer-status". want customer-objects 1 of customer-status-fields xyz.

this not problem if make qb this:

$qb->andwhere($qb->expr()->like('s.comment', ':comment')); $qb->setparameter('comment', "created @ %"); 

the problem is, customers customer-statuses query. these statuses. want statuses if like-query applies.

i have searched found nothing this. idea?

after few beers found anser. expected result should not define customer-status entity in select-operation. select parent-entity. this:

$qb     ->select(['c'])     ->leftjoin('customer.statuses', 's')     ->andwhere($qb->expr()->like('s.comment', ':comment'))     ->setparameter('comment', "created @ %"); 

is right way instead of

$qb     ->select(['c', 's'])     ->leftjoin('customer.statuses', 's')     ->andwhere($qb->expr()->like('s.comment', ':comment'))     ->setparameter('comment', "created @ %"); 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -