prepare("INSERT INTO activity_logs (user_id, user_name, action, details) VALUES (?, ?, ?, ?)"); $detailsStr = is_array($details) || is_object($details) ? json_encode($details, JSON_UNESCAPED_UNICODE) : $details; $stmt->execute([$userId, $userName, $action, $detailsStr]); } catch (\Exception $e) { error_log("Failed to log activity: " . $e->getMessage()); } }