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. [url=https://tadalafilvb.com/]cheap tadalafil 40 mg[/url]

    Reply
  2. Is the one stop purchase all vape products.

    Reply
  3. Is the one stop buy all vape items.

    Reply
  4. I like it when people come together and share views. Great website, continue the good work! http://3.87.65.145/wiki/User:Ricky2971008875

    Reply
  5. Is the one quit look for all vape products.

    Reply
  6. I absolutely love your blog.. Great colors & theme. Did you create this website yourself? Please reply back as I'm wanting to create my own personal blog and want to find out where you got this from or just what the theme is called. Thank you!

    Reply