Last active
February 27, 2017 07:04
-
-
Save sabbir1991/106eebd14a2dd05e1256 to your computer and use it in GitHub Desktop.
Add DB Table from wp plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
register_activation_hook( __FILE__, 'plugin_activate' ); | |
function plugin_activate() { | |
global $wpdb; | |
$table_name = $wpdb->prefix . 'wpems_class'; | |
$sql = "CREATE TABLE IF NOT EXISTS {$table_name} ( | |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | |
`class_name` varchar(255) DEFAULT NULL, | |
`class_numeric_name` int(11) DEFAULT NULL, | |
`teacher_id` int(11) DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;"; | |
require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
dbDelta( $sql ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment