Appearance
Loader
php
final readonly class StanislasPoisson\FrenchPostalCode\Core\LoaderLoads the data into a database, whatever the framework.
- The tables are loaded in the order of their relations.
- A row is inserted with its original identifier, or updated when its identifier exists: running the load twice changes nothing, and a new version of the data updates the rows and adds the new ones.
- Nothing is ever deleted: a closed row has a
valid_todate, so the foreign keys of an application stay valid. - Each table is loaded in one transaction.
replaced_by_city_idpoints to a city that may have a higher identifier, so it is not written with the cities: it is set in a second pass, once every city exists. This keeps the database foreign key.
Source: src/Core/Loader.php
Methods
__construct()
php
public function __construct(Dataset $dataset, RowWriter $rowWriter, RowCaster $rowCaster = new RowCaster(), int $chunkSize = 1000)load()
php
public function load(callable $onTable = null): LoadReport| Parameter | Description |
|---|---|
$onTable | called after each table with its name, its rows and the rows that were added |