我有以下查询:
$this->qb->select('partial transporter.{id,name,transporterType,routes}')
->from($this->entity, 'transporter', null)
->addSelect('partial country.{id,name}')
->addSelect('partial county.{id,shortName}')
->leftJoin('transporter.country', 'country')
->leftJoin('transporter.county', 'county')
and many other selects and joins...
排序,过滤和分页工作正常,直到我添加:
$query->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
$query->setHint(\Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE, $this->locale);
在我添加翻译提示后,排序停止工作,我得到以下异常:
Cannot select distinct identifiers from query with LIMIT and ORDER BY on a column from a fetch joined to-many association. Use output walkers.
我看到了使用Knp Paginator的解决方案,但是我使用了Doctrine的默认分页器。
在我的案例中,解决方案是什么?感谢。
答案 0 :(得分:0)
答案很简单。我只需要将outputwalkers设置为true。
$paginator = new Paginator($this->execute(), true);
$paginator->setUseOutputWalkers(true);