我想在安装我创建的插件后在数据库中创建一个表。
在我的主插件文件(index.php)中:
register_activation_hook(__FILE__, 'wnm_install');
global $wnm_db_version;
$wnm_db_version = "1.0";
function wnm_install(){
global $wpdb;
global $wnm_db_version;
$sql = "CREATE TABLE tbl_campaigns (
campaignID int(11) NOT NULL AUTO_INCREMENT,
campaign_name varchar(128) NOT NULL,
start_duration date NOT NULL,
end_duration date NOT NULL,
activity varchar(500) NOT NULL,
survey_settings varchar(50) NOT NULL,
limit varchar(50) NOT NULL,
goal varchar(100) DEFAULT NULL,
PRIMARY KEY (campaignID)
) ;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
add_option("wnm_db_version", $wnm_db_version);
}
我只是按照此http://codex.wordpress.org/Creating_Tables_with_Plugins中的说明进行操作
但它不起作用。
这段代码似乎有什么问题?