prepare('INSERT INTO settings (key, value) VALUES (?, ?)
ON CONFLICT(key) DO UPDATE SET value = excluded.value');
$st->execute([$key, $value]);
}
function renumber_sorts(PDO $pdo): void
{
$rows = $pdo->query('SELECT id, part, sort FROM articles ORDER BY part ASC, sort ASC, id ASC')->fetchAll();
$idxByPart = [];
$st = $pdo->prepare('UPDATE articles SET sort = ? WHERE id = ?');
foreach ($rows as $r) {
$key = (string)$r['part'];
if (!isset($idxByPart[$key])) {
$idxByPart[$key] = 1;
}
$st->execute([$idxByPart[$key], (int)$r['id']]);
$idxByPart[$key]++;
}
}
function msg_block(string $kind, string $text): string
{
return '