Yii2 dataProvider返回数据条数跟指定pageSize不一致

前两天在编码的过程中,发现使用dataProvider返回的数据条数很奇怪,跟设置的pageSize不一致,而且还是没有规律的那种:

/** @var $provider ActiveDataProvider*/
$provider = new ActiveDataProvider([

    'query' => $query,
    'pagination' => [
        'page' => $currentPage - 1,
        'pageSize' => $pageSize,
    ],
    'sort' => [
        'defaultOrder' => [
            'order_id' => SORT_DESC,
        ]
    ]

]);

比如指定的pageSize是10,但是返回的不是10条,有的页码只有两条

返回结果

一直不知道原因,文档也查不到,搜索也无果,后来问了同事,需要在查询的query加上groupBy();

果真加上就好了,目前还不知道原理,先mark后面再看。

query 加上groupBy

结果正常了:

结果正常

Responses
  1. Have you been searching for escort girls in Tel Aviv ?18escortgirls can make you Want to spend quality young escort girls in your home or hotel? Trying to find Russian escorts, Ethiopian escorts or VIP escorts? Trying to find escort services in Tel Aviv with the truly amazing method of getting 18escortgirls Index can fulfill all of your fantasies discreetly.

    Reply
  2. My brother suggested I might like this website. He was totally right. This post actually made my day. You cann't imagine just how much time I had spent for this information! Thanks!

    Reply
  3. UFA089 เว็บไซต์พนันออนไลน์ คาสิโน พนันบอล ฝาก-ถอน AUTO

    Reply
  4. It's awesome for me to have a website, which is useful designed for my experience. thanks admin

    Reply
  5. Your style is very unique in comparison to other people I have read stuff from. Thank you for posting when you have the opportunity, Guess I'll just book mark this web site.

    Reply
  6. Magnificent beat ! I would like to apprentice even as you amend your website, how can i subscribe for a blog website? The account helped me a appropriate deal. I were a little bit familiar of this your broadcast offered vivid clear concept

    Reply