prepare( "INSERT INTO audit_log ( entity_name, entity_id, action, changed_by, before_data, after_data, context ) VALUES ( :entity_name, :entity_id, :action, :changed_by, :before_data::jsonb, :after_data::jsonb, :context::jsonb )" ); $stmt->execute([ ':entity_name' => $entityName, ':entity_id' => $entityId, ':action' => $action, ':changed_by' => $changedBy, ':before_data' => json_encode($beforeData, JSON_THROW_ON_ERROR), ':after_data' => json_encode($afterData, JSON_THROW_ON_ERROR), ':context' => json_encode($context, JSON_THROW_ON_ERROR), ]); }