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. Drugstore beetle ed medications canadian online pharmacies

    Reply
  2. Greetings from Florida! I'm bored at work so I decided to browse your site on my iphone during lunch break. I love the info you present here and can't wait to take a look when I get home. I'm surprised at how quick your blog loaded on my mobile .. I'm not even using WIFI, just 3G .. Anyways, wonderful blog!

    Reply
  3. Genric cialis us pharmacy cialis good looking loser cialis

    Reply
  4. Hi there! I could have sworn I've been to your blog before but after going through many of the articles I realized it's new to me. Anyways, I'm definitely happy I found it and I'll be book-marking it and checking back regularly!

    Reply
  5. I constantly spent my half an hour to read this weblog's articles or reviews all the time along with a mug of coffee.

    Reply
  6. Thanks for every other magnificent article. The place else may anybody get that kind of information in such an ideal way of writing? I have a presentation next week, and I am on the look for such information.

    Reply