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 are going for most excellent contents like me, only pay a quick visit this web site all the time as it provides quality contents, thanks

    Reply
  2. I take pleasure in, lead to I found just what I used to be looking for. You've ended my 4 day lengthy hunt! God Bless you man. Have a great day. Bye

    Reply
  3. Hi there, after reading this awesome paragraph i am as well happy to share my know-how here with mates.

    Reply
  4. In this way, take a couple of moments to make your profile, message hot ladies in your general vicinity and date easily! Hot singles join .com looking for the sake of entertainment with other receptive individuals in your general vicinity. I'm looking for someone to call mine, and I want a girl that will call me her's. I’m not suggesting you tolerate racists-I’m not even saying that you should open yourself up to potentially suffering them-but these interactions can be so transactional that many guys use what they have to get what they want. Please do not use any celebrities photos, use your own photo only because it will helps you a lot like men can easily trust on real profile instead of dummy account. Visit our Homepage to begin rounding out your profile and start meeting hot singles from your zone (however not really your high rise). In case you're here, it's protected to accept that you're prepared to fan out from essential dating applications and see what the internet brings to the table you.

    Reply
  5. Oh my goodness! Awesome article dude! Thank you, However I am having problems with your RSS. I don't know the reason why I am unable to subscribe to it. Is there anybody else getting identical RSS issues? Anyone that knows the answer will you kindly respond? Thanks!!

    Reply
  6. And your porn for me has been fantastic, some of the best I've seen. Gave me a whole new insight into the "black cock whore" and "posh milf" side of things, love it now, thank you,

    Reply