我不能在WordPress中创建表,我不明白为什么?
private function create($prefix)
{
$sql = "CREATE TABLE " . $prefix . "submit (
submit_id bigint PRIMARY KEY AUTO_INCREMENT,
post_id bigint,
user_id bigint,
author text,
user_email text,
source text,
pass text,
language text,
time datetime,
CONSTRAINT post_id FOREIGN KEY (post_id) REFERENCES wp_posts(ID),
CONSTRAINT user_id FOREIGN KEY (user_id) REFERENCES wp_users(ID)
)";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
var_dump(dbDelta($sql));
}
var_dump()
显示:
数组(1){ [“wp_submit”]=〉字符串(23)“创建的表wp_submit”}
2条答案
按热度按时间jgzswidk1#
请尝试以下代码。
px9o7tmv2#
您可以使用以下代码: