Is it recommended to create a new record in a separate table when editing comments in a PHP application?

When editing comments in a PHP application, it is not recommended to create a new record in a separate table. Instead, you should update the existing record in the database to reflect the changes made to the comment. This ensures that the comment history is maintained and that the original comment can be referenced if needed.

// Update comment in database
$commentId = $_POST['comment_id'];
$newComment = $_POST['new_comment'];

$sql = "UPDATE comments SET comment = :new_comment WHERE id = :comment_id";
$stmt = $pdo->prepare($sql);
$stmt->execute(['new_comment' => $newComment, 'comment_id' => $commentId]);