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. I love it whenever people get together and share views. Great blog, stick with it!

    Reply
  2. This is a topic that's close to my heart... Thank you! Exactly where are your contact details though?

    Reply
  3. Awesome post.

    Reply
  4. I really like it when individuals come together and share opinions. Great website, stick with it!

    Reply
  5. I was recommended this blog via my cousin. I am no longer positive whether this put up is written by way of him as no one else recognize such particular approximately my problem. You're incredible! Thank you!

    Reply
  6. plgrn.nl https://openproductdata.ch balance of nature Lucretia classicalmusicmp3freedownload.com

    Reply