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. If you wish for to get a great deal from this piece of writing then you have to apply these methods to your won webpage.

    Reply
  2. and recent field work has identified two additional levels vertically higher, which indicate that there are the opportunity for additional resources to be defined both along dip. Shares often move in a short time in one direction, and also this trend can are far more than expected, which creates two problems. Q1: How can I buy tax liens or tax deeds without going on the auction.

    Reply
  3. I am extremely impressed along with your writing talents as smartly as with the format to your blog. Is this a paid subject matter or did you modify it your self? Anyway keep up the excellent quality writing, it's uncommon to see a nice weblog like this one these days..

    Reply
  4. w88

    Wow, that's what I was searching for, what a information! existing here at this website, thanks admin of this web page.

    Reply
  5. Does anybody here on kangxuanpeng.com would llike to tuгn into a Hemp and CBD reviewer wіtһ us аnd review hemp infused products ⅼike CBD Infused Gummies Ԍet іn touch if you woupd like to get involved

    Reply
  6. Someone essentially lend a hand to make critically posts I would state. This is the first time I frequented your website page and so far? I surprised with the analysis you made to create this actual submit amazing. Wonderful task!

    Reply