FHM31052601IBL - fix syntax migrate_encrypt_results.php compat PHP 7.2
Ganti arrow function fn() ke closure biasa karena server pakai PHP 7.2 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,13 +32,17 @@ $pdo = new PDO(
|
||||
$batch = 500;
|
||||
|
||||
// Helper: migrate tabel dengan field-field sederhana (tanpa bidx)
|
||||
function migrate_simple(PDO $pdo, Ibl_encryptor $enc, string $table, string $pk, array $fields, string $check_field): void
|
||||
function migrate_simple(PDO $pdo, Ibl_encryptor $enc, $table, $pk, $fields, $check_field)
|
||||
{
|
||||
echo "=== {$table} ===\n";
|
||||
$total = 0;
|
||||
$cols_sel = implode(', ', array_merge([$pk], $fields));
|
||||
$sets = implode(', ', array_map(fn($f) => "{$f}_enc = ?", $fields));
|
||||
$stmt = $pdo->prepare("UPDATE {$table} SET {$sets} WHERE {$pk} = ?");
|
||||
$total = 0;
|
||||
$cols_sel = implode(', ', array_merge([$pk], $fields));
|
||||
$set_parts = array();
|
||||
foreach ($fields as $f) {
|
||||
$set_parts[] = "{$f}_enc = ?";
|
||||
}
|
||||
$sets = implode(', ', $set_parts);
|
||||
$stmt = $pdo->prepare("UPDATE {$table} SET {$sets} WHERE {$pk} = ?");
|
||||
|
||||
while (true) {
|
||||
$rows = $pdo->query(
|
||||
@@ -48,7 +52,10 @@ function migrate_simple(PDO $pdo, Ibl_encryptor $enc, string $table, string $pk,
|
||||
if (empty($rows)) break;
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$params = array_map(fn($f) => $enc->encrypt((string)($row[$f] ?? '')), $fields);
|
||||
$params = array();
|
||||
foreach ($fields as $f) {
|
||||
$params[] = $enc->encrypt((string)(isset($row[$f]) ? $row[$f] : ''));
|
||||
}
|
||||
$params[] = $row[$pk];
|
||||
$stmt->execute($params);
|
||||
$total++;
|
||||
|
||||
Reference in New Issue
Block a user