我正在开发一个插件。我想通过插件创建一个表。所以我尝试执行下面的SQL查询。
global $wpdb;
$createSQL = "
CREATE TABLE `". $wpdb->prefix ."_book_ratings` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`book_id` bigint(20) UNSIGNED NOT NULL,
`rating` float(3.1) UNSIGNED NOT NULL,
`user_ip` varchar(32) NOT NULL
) ENGINE=InnoDB" . $wpdb->get_charset_collate() . " AUTO_INCREMENT=1;
";
require( ABSPATH . \'/wp-admin/includes/upgrade.php\' );
dbDelta( $createSQL );
当我停用插件和重新激活插件时,我会遇到以下错误。The plugin generated 464 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.