简体   繁体   中英

OrderBy a relation in an entity

I've got a headache :) Been trying to google this for an hour, and before that trying to solve it for an hour.

I've got an entity A with a ManyToOne relation to another entity B. I need to sort a select of A by one of B's parameters.

ie $qb->addOrderBy('p.dogShowClass.weight', 'ASC')

I'm lost. Help! :) I will be monitoring this closely, if you need any further details, please do write and I will get it to you ASAP

$query = $repo->createQueryBuilder('p')
    ->join('p.dogShowClass', 'd')
    ->orderBy('d.weight', 'ASC')
    ->getQuery()
;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM