The minimun version of PHP required by this package is PHP 8.1.
For install this package, you need composer.
composer require yii-tools/data-provider
<?php
declare(strict_types=1);
use Yii\DataProvider\ActiveIteratorDataProvider;
use Yiisoft\ActiveRecord\ActiveQuery;
use Yiisoft\Db\Connection\ConnectionInterface;
/** @var ConnectionInterface $db */
$userQuery = new ActiveQuery(User::class, $db);
$activeIteratorDataProvider = new ActiveDataProvider($userQuery);
<?php
declare(strict_types=1);
use Yii\DataProvider\ArrayIteratorDataProvider;
$arrayIteratorDataProvider = new ArrayIteratorDataProvider(
[
['id' => 1, 'name' => 'name1'],
['id' => 2, 'name' => 'name2'],
['id' => 3, 'name' => 'name3'],
],
);
<?php
declare(strict_types=1);
use Yii\DataProvider\QueryIteratorDataProvider;
/** @var ConnectionInterface $db */
$queryIteratorDataProvider = new QueryIteratorDataProvider((new Query($db))->select('*')->from('{{%user}}'));
<?php
declare(strict_types=1);
use Yii\DataProvider\SQLIteratorDataProvider;
use Yiisoft\Db\Connection\ConnectionInterface;
/** @var ConnectionInterface $db */
$sqlIteratorDataProvider = new SQLIteratorDataProvider($db, 'SELECT * FROM {{%user}}');
Check the documentation testing to learn about testing.
The MIT License (MIT). Please see License File for more information.