![](/img/trans.png)
[英]How to add filter to configureListField in Sonata Admin Bundle (createQuery method)
[英]How to fix “The query returned multiple rows” in sonata admin, when groupby in createQuery
我正在使用createQuery()
為configureListFields()
在Sonata admin中編寫一個簡單的代碼。
當我寫groupby
,出現以下錯誤:
查詢返回多行。 更改查詢或使用其他結果函數,如
getScalarResult()
。
public function createQuery($context = 'list')
{
$query = parent::createQuery($context);
$rootAlias = $query->getRootAliases()[0];
$query->groupby($rootAlias.'.cityId');
return $query;
}
由於默認分頁器中的錯誤,您必須使用“簡單”的尋呼機,如此處所述。
https://stackoverflow.com/a/48803077/7135824
在service.yaml
tags:
- { name: sonata.admin, pager_type: "simple", ...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.