diff --git a/models/CommentModel.php b/models/CommentModel.php index 03eabd1..4dcc4a0 100644 --- a/models/CommentModel.php +++ b/models/CommentModel.php @@ -147,7 +147,19 @@ class CommentModel { return ['success' => false, 'error' => 'You do not have permission to edit this comment']; } - $sql = "UPDATE ticket_comments SET comment_text = ?, markdown_enabled = ?, updated_at = NOW() WHERE comment_id = ?"; + // Check if updated_at column exists + $hasUpdatedAt = false; + $colCheck = $this->conn->query("SHOW COLUMNS FROM ticket_comments LIKE 'updated_at'"); + if ($colCheck && $colCheck->num_rows > 0) { + $hasUpdatedAt = true; + } + + if ($hasUpdatedAt) { + $sql = "UPDATE ticket_comments SET comment_text = ?, markdown_enabled = ?, updated_at = NOW() WHERE comment_id = ?"; + } else { + $sql = "UPDATE ticket_comments SET comment_text = ?, markdown_enabled = ? WHERE comment_id = ?"; + } + $stmt = $this->conn->prepare($sql); $markdownInt = $markdownEnabled ? 1 : 0; $stmt->bind_param("sii", $commentText, $markdownInt, $commentId); @@ -158,7 +170,7 @@ class CommentModel { 'comment_id' => $commentId, 'comment_text' => $commentText, 'markdown_enabled' => $markdownInt, - 'updated_at' => date('M d, Y H:i') + 'updated_at' => $hasUpdatedAt ? date('M d, Y H:i') : null ]; } else { return ['success' => false, 'error' => $this->conn->error];