Plugin not creating table on activation
-
My plugin doesn’t create table on activation SQL code is right and other parts of code seems right too. Why It doesn’t work ?
class MySimpleForm { public function __construct() { /*** Includes ***/ include_once plugin_dir_path(__FILE__).'/db.php'; /*** Instanciation ***/ register_activation_hook(__FILE__, array('MySimpleForm','install')); } public static function install() { MSF_db::createTable(); } } new MySimpleForm();db.php file
class MSF_db { public function __construct() { } public static function createTable() { global $wpdb; $wpdb->query('CREATE TABLE IF NOT EXISTS {$wpdb->prefix}msf_form_data (id INT PRIMARY KEY, firstname VARCHAR(50) NOT NULL, lastname VARCHAR(50) NOT NULL, email VARCHAR(200) NOT NULL);'); } public static function dropTable() { } }
The topic ‘Plugin not creating table on activation’ is closed to new replies.