修复webhook.php中的TIMESTAMP限制问题:将TIMESTAMP字段改为DATETIME字段
This commit is contained in:
+22
-2
@@ -307,6 +307,14 @@ function store_form_data_to_db($form_data) {
|
||||
// 创建WPS表单数据表(只包含实际需要的字段)
|
||||
function create_wps_form_table($pdo) {
|
||||
try {
|
||||
// 先检查表是否存在
|
||||
$check_sql = "SHOW TABLES LIKE 'wps_form_submissions'";
|
||||
$result = $pdo->query($check_sql);
|
||||
if ($result->rowCount() > 0) {
|
||||
log_message("表wps_form_submissions已存在");
|
||||
return true;
|
||||
}
|
||||
|
||||
$sql = "CREATE TABLE IF NOT EXISTS wps_form_submissions (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
rid VARCHAR(50) NOT NULL COMMENT '表单提交ID',
|
||||
@@ -328,18 +336,30 @@ function create_wps_form_table($pdo) {
|
||||
age_group VARCHAR(20) COMMENT '请选择年龄段',
|
||||
remarks TEXT COMMENT '备注内容',
|
||||
status VARCHAR(20) DEFAULT 'pending' COMMENT '状态',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
|
||||
updated_at TIMESTAMP DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '记录更新时间',
|
||||
INDEX idx_rid (rid),
|
||||
INDEX idx_license_plate (license_plate),
|
||||
INDEX idx_date (date),
|
||||
INDEX idx_mobile (mobile)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
|
||||
|
||||
log_message("开始执行创建表SQL: " . substr($sql, 0, 200) . "...");
|
||||
$pdo->exec($sql);
|
||||
log_message("表wps_form_submissions创建成功");
|
||||
|
||||
// 再次检查表是否真的存在
|
||||
$result = $pdo->query($check_sql);
|
||||
if ($result->rowCount() > 0) {
|
||||
log_message("表wps_form_submissions确实存在");
|
||||
} else {
|
||||
log_message("表wps_form_submissions创建后仍不存在", 'error');
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
log_message("创建表失败: " . $e->getMessage(), 'error');
|
||||
log_message("错误代码: " . $e->getCode(), 'error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user