yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.9k forks source link

SqlDataProvider and totalCount without pagination #20178

Closed dfuse-dev closed 5 months ago

dfuse-dev commented 5 months ago

What steps will reproduce the problem?

Seems that 'totalCount' is needed now even if no pageSize is configured.

$dataProvider = new SqlDataProvider([
      'sql' => $query,
      'params' => $boundParams,
      'pagination' => [
        'pageSize' => 0,
      ],
    ]);

What is the expected result?

That worked before to get all records

What do you get instead?

now it throws error "Call to a member function getQueryBuilder() on string" in /var/www/t3/vendor/yiisoft/yii2/db/Query.php (157)

but if i set totalCount

$dataProvider = new SqlDataProvider([
      'sql' => $query,
      'params' => $boundParams,
      'totalCount' => 0,
      'pagination' => [
        'pageSize' => 0,
      ],
    ]);

it works again

Additional info

Q A
Yii version 2.0.50
PHP version 8.2.18
Operating system Debian 12
bizley commented 5 months ago

Does #20176 help?

dfuse-dev commented 5 months ago

not really, my attempt has also the $query before pagination and throws the error. Maybe this is only related to SqlDataProvider