Files
SunShineMusic/add_db.php
2025-09-24 14:14:45 +00:00

27 lines
922 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// 运行此脚本为推荐表添加状态字段
require 'db_connect.php';
if ($pdo) {
try {
// 检查是否已存在status字段
$result = $pdo->query("SHOW COLUMNS FROM recommendations LIKE 'status'");
$columnExists = $result->fetch();
if (!$columnExists) {
// 添加状态字段0:待审核, 1:已同意, 2:已驳回)
$pdo->exec("ALTER TABLE recommendations
ADD COLUMN status TINYINT NOT NULL DEFAULT 0,
ADD COLUMN reviewed_at DATETIME NULL");
echo "状态字段添加成功!请刷新页面继续操作。";
} else {
echo "状态字段已存在,无需重复添加。";
}
} catch(PDOException $e) {
die("操作失败: " . $e->getMessage());
}
} else {
die("数据库连接失败,请先检查连接配置。");
}
?>