2017-05-29 58 views
0

我有以下查詢:Gedmo可翻譯與學說分頁程序

$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

答案很簡單。我只需要將輸出行程設置爲true。

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