12 lines
528 B
PHP
12 lines
528 B
PHP
<?php
|
|
function log_audit_trail(PDO $pdo, string $action, array $details, string $user = 'system') {
|
|
try {
|
|
$stmt = $pdo->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());
|
|
}
|
|
}
|