【问题标题】:Gedmo Translatable with Doctrine PaginatorGedmo 可使用 Doctrine Paginator 进行翻译
【发布时间】:2017-05-29 12:04:58
【问题描述】:

我有以下疑问:

$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 中的默认分页器。

在我的情况下,解决方案是什么?谢谢。

【问题讨论】:

    标签: doctrine-orm symfony-2.7


    【解决方案1】:

    答案很简单。我只需要将 outputwalkers 设置为 true。

    $paginator = new Paginator($this->execute(), true);
    $paginator->setUseOutputWalkers(true);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-12
      • 1970-01-01
      • 2015-03-17
      • 2014-06-12
      • 2011-11-29
      • 1970-01-01
      • 2020-07-08
      相关资源
      最近更新 更多