generated from yii-tools/template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
QueryIteratorDataProvider::class
. (#8)
- Loading branch information
1 parent
5a9de9c
commit e5fae94
Showing
18 changed files
with
874 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yii\DataProvider; | ||
|
||
use Yiisoft\Db\Query\QueryInterface; | ||
|
||
final class QueryIteratorDataProvider extends AbstractIteratorDataDataProvider | ||
{ | ||
public function __construct(private QueryInterface $query) | ||
{ | ||
} | ||
|
||
public function count(): int | ||
{ | ||
return (int) $this->query->count('*'); | ||
} | ||
|
||
public function read(): array | ||
{ | ||
return $this->query->limit($this->limit)->offset($this->offset)->all(); | ||
} | ||
|
||
public function readOne(): array | ||
{ | ||
return $this->query->limit(1)->offset($this->offset)->all(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.