Standalone Database Library
Use the standalone format-neutral PDO library for validation, mapping, domain imports, SQL batches, manifests, failed rows, and database cursors.
Updated
SqlImporter::importRows()DomainImporter::create()DatabaseConnectionFactory::make()What you will learn
- Install database workflows without automatically installing XLSX.
- Import any iterable row source into PDO.
- Add the source format package or the database-XLSX bridge only when required.
Install the format-neutral PDO package#
composer require mnb/mnb-phpexcel-database:^2.0This package requires only Core and ext-pdo. It does not install XLSX or any other format reader.
Import rows from any source#
use Mnb\PHPExcel\Import\SqlImporter;
$result = (new SqlImporter())->importRows(
$pdo,
'customers',
$rows,
[
'batch_size' => 500,
'duplicate_strategy' => 'skip',
]
);$rows may be an array, generator, database cursor, CSV session, JSON session, XML session, native XLS session, native XLSX session, or another iterable normalized by your application.
Install source formats separately#
| Need | Install |
|---|---|
| CSV rows into PDO | mnb/mnb-phpexcel-database:^2.0 + mnb/mnb-phpexcel-csv:^2.0 |
| Native XLS rows into PDO | mnb/mnb-phpexcel-database:^2.0 + mnb/mnb-phpexcel-xls:^2.0 |
| Normal XLSX rows into PDO | mnb/mnb-phpexcel-database:^2.0 + mnb/mnb-phpexcel-xlsx:^2.0 |
| Very large XLSX direct streaming | mnb/mnb-phpexcel-database-xlsx:^2.0 |
| Complete mono library | mnb/mnb-phpexcel:^2.0 instead of individual libraries |
Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue