簡體   English   中英

在createQuery中使用groupby時,如何在sonata admin中修復“查詢返回多行”

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM