fetch(PDO::FETCH_ASSOC)) { $new = strtoupper('baad1d00-9491-4716-b98b-' . preg_replace('/[^0-9a-f]/i', '', $row['macaddr'])); error_log('Replacing ' . $row['machineuuid'] . ' with ' . $new); if (strlen($new) === 36) { if (Database::exec("UPDATE machine SET machineuuid = :new WHERE machineuuid = :old", ['old' => $row['machineuuid'], 'new' => $new]) === false) { error_log('Result: ' . Database::lastError()); Database::exec("DELETE FROM machine WHERE machineuuid = :old", ['old' => $row['machineuuid']]); } } } // Create response responseFromArray($res);