dbdelta creat table inconsistent behavior
-
I have been getting really inconsistent behavior with the use of dbdelta recently (likely since 4.4.2 upgrade). The following (seemingly a bug) has been driving me crazy.
$table_name = $wpdb->prefix . "rbelegvote"; $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, email varchar(120) NOT NULL, twitid varchar(120) NOT NULL, PRIMARY KEY (id), KEY (email) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql);works, however putting an underscore in the table name so it becomes:
$table_name = $wpdb->prefix . "rbe_legvote"; $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, email varchar(120) NOT NULL, twitid varchar(120) NOT NULL, PRIMARY KEY (id), KEY (email) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql);does not work. I have tried this like 10 times to make sure I wasn’t doing something stupid. Can anyone out there tell my why the first one would work and the second one wouldn’t? The second one used to work and no longer does, and I think I obeyed all the strange spacing requirements for db delta. I am suspecting this has to do with the wordpress update but not sure. Thank you in advance
The topic ‘dbdelta creat table inconsistent behavior’ is closed to new replies.