You should be familiar with already, as you should be using it to create the table. On your install hook you should have something like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | $charset_collate = ''; if ( ! empty($wpdb->charset) ) $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; if ( ! empty($wpdb->collate) ) $charset_collate .= " COLLATE $wpdb->collate"; //Create custom table $sql_custom_table ="CREATE TABLE {$wpdb->prefix}my_table ( id bigint(20) unsigned NOT NULL auto_increment, column_a varchar(255) default NULL, column_b varchar(255) default NULL, PRIMARY KEY (id) ) $charset_collate; "; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql_custom_table); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.