Actualiser api/index.php
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
Security Scan (Trivy) / Trivy — Docker image scan (push) Has been cancelled
Security Scan (Trivy) / Trivy — Filesystem scan (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
Security Scan (Trivy) / Trivy — Docker image scan (push) Has been cancelled
Security Scan (Trivy) / Trivy — Filesystem scan (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
This commit is contained in:
+14
-3
@@ -8990,7 +8990,7 @@ function importMergeBackup(PDO $db): void {
|
|||||||
|
|
||||||
$db->beginTransaction();
|
$db->beginTransaction();
|
||||||
try {
|
try {
|
||||||
// --- 1. Tables référentielles simples : skip si key existe ---
|
// --- 1. Tables référentielles simples : upsert (update label/icon si key existe déjà) ---
|
||||||
$refTables = [
|
$refTables = [
|
||||||
'categories' => ['key'],
|
'categories' => ['key'],
|
||||||
'locations' => ['key'],
|
'locations' => ['key'],
|
||||||
@@ -9004,9 +9004,20 @@ function importMergeBackup(PDO $db): void {
|
|||||||
$where = [];
|
$where = [];
|
||||||
$params = [];
|
$params = [];
|
||||||
foreach ($uniqueCols as $c) { $where[] = "$c = ?"; $params[] = $row[$c]; }
|
foreach ($uniqueCols as $c) { $where[] = "$c = ?"; $params[] = $row[$c]; }
|
||||||
$exists = $db->prepare("SELECT 1 FROM {$table} WHERE " . implode(' AND ', $where));
|
$exists = $db->prepare("SELECT id FROM {$table} WHERE " . implode(' AND ', $where));
|
||||||
$exists->execute($params);
|
$exists->execute($params);
|
||||||
if ($exists->fetch()) continue;
|
$existingId = $exists->fetchColumn();
|
||||||
|
if ($existingId) {
|
||||||
|
// Update label/icon (and keywords if present) from prod, keep local id/is_builtin
|
||||||
|
$updCols = array_diff(array_keys($row), $uniqueCols, ['is_builtin', 'sort_order']);
|
||||||
|
if (!empty($updCols)) {
|
||||||
|
$setClause = implode(', ', array_map(fn($c) => "$c = ?", $updCols));
|
||||||
|
$updParams = array_map(fn($c) => $row[$c], $updCols);
|
||||||
|
$updParams[] = $existingId;
|
||||||
|
$db->prepare("UPDATE {$table} SET {$setClause} WHERE id = ?")->execute($updParams);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$cols = array_keys($row);
|
$cols = array_keys($row);
|
||||||
$stmt = $db->prepare("INSERT INTO {$table} (" . implode(',', $cols) . ") VALUES (" . implode(',', array_fill(0, count($cols), '?')) . ")");
|
$stmt = $db->prepare("INSERT INTO {$table} (" . implode(',', $cols) . ") VALUES (" . implode(',', array_fill(0, count($cols), '?')) . ")");
|
||||||
$stmt->execute(array_values($row));
|
$stmt->execute(array_values($row));
|
||||||
|
|||||||
Reference in New Issue
Block a user