PHP code example of sdragnev / bulkdbinserter
1. Go to this page and download the library: Download sdragnev/bulkdbinserter library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sdragnev / bulkdbinserter example snippets
// 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