yii-tools/data-provider

Proveedores de datos para Yii3.

dev-main / 1.0.x-dev 2023-06-27 15:45 UTC

This package is auto-updated.

Last update: 2024-11-30 02:33:25 UTC


README

Data Provider for YiiFramework v. 3.0.


Requirements

The minimun version of PHP required by this package is PHP 8.1.

For install this package, you need composer.

Install

composer require yii-tools/data-provider

Usage

ActiveIteratorDataProvider

<?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);

ArrayIteratorDataProvider

<?php

declare(strict_types=1);

use Yii\DataProvider\ArrayIteratorDataProvider;

$arrayIteratorDataProvider = new ArrayIteratorDataProvider(
    [
        ['id' => 1, 'name' => 'name1'],
        ['id' => 2, 'name' => 'name2'],
        ['id' => 3, 'name' => 'name3'],
    ],
);

QueryIteratorDataProvider

<?php

declare(strict_types=1);

use Yii\DataProvider\QueryIteratorDataProvider;

/** @var ConnectionInterface $db */
$queryIteratorDataProvider = new QueryIteratorDataProvider((new Query($db))->select('*')->from('{{%user}}'));

SQLIteratorDataProvider

<?php

declare(strict_types=1);

use Yii\DataProvider\SQLIteratorDataProvider;
use Yiisoft\Db\Connection\ConnectionInterface;

/** @var ConnectionInterface $db */
$sqlIteratorDataProvider = new SQLIteratorDataProvider($db, 'SELECT * FROM {{%user}}');

Testing

Check the documentation testing to learn about testing.

CI status

Build Status codecov Mutation testing badge static analysis type-coverage StyleCI

License

The MIT License (MIT). Please see License File for more information.

Our social networks

Twitter