prepare("INSERT INTO audit_log (user, action, details) VALUES (?, ?, ?)"); $stmt->execute([$user, $action, json_encode($details)]); } catch (PDOException $e) { // For now, we will log the error to the system's error log. // In a production environment, this should be handled more robustly. error_log('Failed to log audit trail: ' . $e->getMessage()); } }