sdragnev / bulkdbinserter
Create a database writer using PDO to support multiple row insertion
Installs: 34
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/sdragnev/bulkdbinserter
Requires
- php: >=5.6.0
- ext-pdo: *
This package is auto-updated.
Last update: 2025-12-28 00:08:32 UTC
README
Helper class that can buffer multiple PDO writes into one query.
Example usage, inserting 1200 records in the "accounts" table given an existing PDO connection object $pdo, 500 (default) records at a time:
// Inserts 1200 records in 3 queries (500 + 500 + 200)
$writer = new BulkInserter($pdo, "accounts", ["id", "name"]);
// $writer->setBatch(600); // optionally set the buffer size to a different number
for ($i = 0; $i < 1200; $i++) {
$writer->write([$i, "John $i"]);
}
$writer->flush(true); // flushes the remaining buffer