<?php
require_once 'includes/config.php';
require_once 'includes/db.php';

// Update the product_comments table to properly support UTF-8 emojis
try {
    // Update the comment column to use utf8mb4 encoding
    $sql = "ALTER TABLE `product_comments` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
    $pdo->exec($sql);
    
    // Also update the comment column specifically
    $sql = "ALTER TABLE `product_comments` CHANGE `comment` `comment` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL";
    $pdo->exec($sql);
    
    echo "Table 'product_comments' updated to support UTF-8 emojis successfully!";
    
    echo "<br><br><a href='products/view.php?id=2'>View Product with Comments</a>";
} catch (Exception $e) {
    echo "Error updating table: " . $e->getMessage();
}
?>