public static function install($force = false) { $db_version = 1.2; // this is the version of the database we're moving to $old_db_version = get_site_option('frmpro_copies_db_version'); global $wpdb; if ($db_version != $old_db_version || $force) { $force = true; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $frmdb = new FrmDb(); $charset_collate = $frmdb->collation(); /* Create/Upgrade Display Table */ $sql = 'CREATE TABLE ' . self::table_name() . ' ( id int(11) NOT NULL auto_increment, type varchar(255) default NULL, copy_key varchar(255) default NULL, form_id int(11) default NULL, blog_id int(11) default NULL, created_at datetime NOT NULL, PRIMARY KEY id (id), KEY form_id (form_id), KEY blog_id (blog_id) ) ' . $charset_collate . ';'; dbDelta($sql); update_site_option('frmpro_copies_db_version', $db_version); } self::copy_forms($force); }
private function assert_collation() { global $wpdb; $frmdb = new FrmDb(); $collation = $frmdb->collation(); if (!empty($wpdb->charset)) { $this->assertNotEmpty(strpos($collation, 'DEFAULT CHARACTER SET')); } if (!empty($wpdb->collate)) { $this->assertNotEmpty(strpos($collation, 'COLLATE')); } }