上传文件至 /
This commit is contained in:
26
add_db_2.php
Normal file
26
add_db_2.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
// 运行此脚本为推荐表添加用户标识字段
|
||||
require 'db_connect.php';
|
||||
|
||||
if ($pdo) {
|
||||
try {
|
||||
// 检查是否已存在user_identifier字段
|
||||
$result = $pdo->query("SHOW COLUMNS FROM recommendations LIKE 'user_identifier'");
|
||||
$columnExists = $result->fetch();
|
||||
|
||||
if (!$columnExists) {
|
||||
// 添加用户标识字段(用于区分不同用户的推荐)
|
||||
$pdo->exec("ALTER TABLE recommendations
|
||||
ADD COLUMN user_identifier VARCHAR(255) NOT NULL DEFAULT ''");
|
||||
|
||||
echo "用户标识字段添加成功!请刷新页面继续操作。";
|
||||
} else {
|
||||
echo "用户标识字段已存在,无需重复添加。";
|
||||
}
|
||||
} catch(PDOException $e) {
|
||||
die("操作失败: " . $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
die("数据库连接失败,请先检查连接配置。");
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user