Create Database table

function myplugin_create_database_table() {
global $wpdb;
$table = $wpdb->prefix . ‘myplugin_table_name’;

$sql = “CREATE TABLE ” . $table . ” (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL DEFAULT ”,
email VARCHAR(100) NOT NULL DEFAULT ”,
UNIQUE KEY id (id)
);”;

require_once(ABSPATH . ‘wp-admin/includes/upgrade.php’);
dbDelta($sql);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s