Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 725 Bytes

README.md

File metadata and controls

35 lines (26 loc) · 725 Bytes

Build Status

important

Simple library showing how to use an inverse generator to act as a batch importer

Configuration

composer require azphp/important

Usage

<?php

$batcher = function (array $values)
{
    /** @var \PDO $myDb */
    $stmt = $myDb->query('INSERT blah blah');
    // maybe do some data transformation
    $stmt->execute($values);
};

$importer = \AzPHP\Important\Importer::createImporter(
    $batcher,
    100
);

/** @var iterable $someData */
foreach ($someData as $value) {
    $importer->send($value);
}

// finish any extra values not covered by a batch
$importer->send(null);