Aller au contenu

Missing Bulk Operation (ARCH7053)

Ce contenu n’est pas encore disponible dans votre langue.

Key php.orm.missing-bulk-operation · Severity warning · Category orm

Repeating single-row operations in a loop when a bulk/batch API exists (insert, createMany, upsert) is wasteful. Collapsing to one bulk call drastically reduces round-trips.

<?php
foreach ($items as $item) {
Product::create(['sku' => $item['sku']]); // one INSERT per row
}
<?php
$payload = array_map(fn($i) => ['sku' => $i['sku']], $items);
Product::insert($payload); // single bulk INSERT

Collapse the repeated single-row operations into a bulk API like insert/createMany.