wpdb to create table is driving me nuts! Please help
-
Okay, what am I doing wrong? Writing a plugin that creates a table. Here is my code but it never creates the table.
I have other functions in the plugin that work fine.
function myplugin_install() { global $wpdb; $table_name = $wpdb->prefix . "myplugtable"; if($wpdb->get_var("show tables like '$table_name'") != $table_name) { $sql = "CREATE TABLE " . $table_name . " ( Title varchar(250) NOT NULL, Owner varchar(256) NOT NULL, Available datetime NOT NULL, Status varchar(256) NOT NULL, Sound varchar(256) NOT NULL, Versions int(11) NOT NULL, UNIQUE KEY ID (ID) ); "; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); } }
And of course I am calling this via…
register_activation_hook(__FILE__,'myplugin_install');
Any help is mucho appreciated!
Cheers.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘wpdb to create table is driving me nuts! Please help’ is closed to new replies.