Skip to content

Loader ​

php
final readonly class StanislasPoisson\FrenchPostalCode\Core\Loader

Loads 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_to date, so the foreign keys of an application stay valid.
  • Each table is loaded in one transaction.
  • replaced_by_city_id points 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
ParameterDescription
$onTablecalled after each table with its name, its rows and the rows that were added

Documentation of next , built from 068662f on main by pipeline #37508150537 on 2026-10-06.