I hate to bring up old threads but I have the same issue and for the life of me I can not figure out what the solution is. I have tried known good sql from other plugins that I am currently using and simply renaming the table name and that still did not work for me. I’m using the cpanel editor so I doubt there are stray hidden characters but even if there were I am copying known good code and it’s not working. There has to be another problem other than the SQL. Can someone please help me. I have been at this for 2 days now.
/*--------------------------------------------------------------------------*/
/* Database Table Setup */
/*--------------------------------------------------------------------------*/
$pr_db_version = "1.0";
global $wpdb;
// add database pointer
$wpdb->pr_orders = $wpdb->prefix . 'pr_orders';
$wpdb->pr_vendors = $wpdb->prefix . 'pr_vendors';
$wpdb->pr_approvals = $wpdb->prefix . 'pr_approvals';
$wpdb->pr_items = $wpdb->prefix . 'pr_items';
function pr_db_install () {
global $wpdb;
global $pr_db_version;
//Concat WordPress DB prefix to table name and Assign Table Names to Variables
$pr_orders = $wpdb->prefix . "pr_orders";
$pr_vendors = $wpdb->prefix . "pr_vendors";
$pr_approvals = $wpdb->prefix . "pr_approvals";
$pr_items = $wpdb->prefix . "pr_items";
//Check if pr_orders table already exist and create if not
if($wpdb->get_var("SHOW TABLES LIKE '$pr_orders'") != $pr_orders){
$sql = "CREATE TABLE " . $pr_orders . " (
pr_approval_id BIGINT(20) NOT NULL AUTO_INCREMENT ,
user_id BIGINT(20) NOT NULL ,
pr_order_id BIGINT(20) NOT NULL ,
pr_voter_priority BIGINT(3) NOT NULL ,
pr_treasurer_approved BOOLEAN NULL ,
pr_president_approved BOOLEAN NULL ,
pr_secretary_approved BOOLEAN NULL,
pr_approval_date_added DATETIME NOT NULL ,
pr_approval_date_changed DATETIME NULL ,
pr_approval_comment VARCHAR(255) NULL ,
PRIMARY KEY (pr_approval_id) ,
KEY pr_type (pr_type) ,
KEY pr_status(pr_status)
);";
dbDelta($sql);
}
}
register_activation_hook(__FILE__,'pr_db_install');
/*--------------------------------------------------------------------------*/
/* End Database Table Setup */
/*--------------------------------------------------------------------------*/
//**************************************************************************//