add_action("after_switch_theme", "my_custom_table_setup");
function my_custom_table_setup()
{
global $wpdb;
$create_table_query = "
CREATE TABLE {$wpdb->prefix}products_by_sku (
id int(11) NOT NULL auto_increment,
product_id int(11) NOT NULL,
lot_id varchar(25) NOT NULL,
title varchar(255) NOT NULL,
LP varchar(25) NOT NULL,
catgeory varchar(255) NOT NULL,
product_name varchar(255) NOT NULL,
UPC varchar(255) DEFAULT NULL,
ASIN varchar(255) DEFAULT NULL,
original_retail_price float DEFAULT NULL,
quantity int(11) DEFAULT NULL,
total_original_retail float NOT NULL DEFAULT 0,
stock_image text,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $create_table_query );
}
试试这个代码。
非常感谢。