Skip to content

Commit 69109c1

Browse files
committed
without totalCount
1 parent 4772976 commit 69109c1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"require": {
1414
"php": ">=7.2.0",
1515
"ext-pdo": "*",
16-
"yiisoft/yii2": "~2.0.0"
16+
"yiisoft/yii2": "~2.0.0",
17+
"smoren/query-relation-manager": "1.0.0"
1718
},
1819
"autoload": {
1920
"psr-4": {

src/ActiveRecord/QueryRelationDataProvider.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Smoren\Yii2\QueryRelationManager\ActiveRecord;
55

66

7+
use Smoren\Yii2\QueryRelationManager\Base\QueryRelationManagerException;
78
use yii\data\BaseDataProvider;
89
use yii\db\Connection;
910
use yii\db\Query;
@@ -27,6 +28,11 @@ class QueryRelationDataProvider extends BaseDataProvider
2728
*/
2829
public $key;
2930

31+
/**
32+
* @var bool Не считать totalCount
33+
*/
34+
public $withoutTotalCount = false;
35+
3036
/**
3137
* Prepares the data models that will be made available in the current page.
3238
* @return array the available data models
@@ -93,7 +99,10 @@ protected function prepareKeys($models)
9399
*/
94100
protected function prepareTotalCount()
95101
{
96-
// TODO слабое место: сильно снижает производительность!!! Возможно необходимо сделать рассчет опциональным
102+
if($this->withoutTotalCount) {
103+
return 0;
104+
}
105+
97106
return $this->queryRelationManager
98107
->prepare()
99108
->getQuery()

0 commit comments

Comments
 (0)