I'm following this to make my plugin auto-create a table when the plugin is activated, but what happens is that while all the tables (the whole db) are utf8_general_ci, the newly created table is latin1_swedish_ci... Why isn't it also utf8? I thought it would also be utf8 by default since I have:
define('DB_COLLATE', 'utf8_general_ci');
in my wp-config.php... I have everything exactly the same like in the link provided, except the function name, and I have different SQL fields... How to make the newly created table utf8 by default?
this is my function:
function duende_install() {
global $wpdb;
global $duende_db_version;
$table_name = $wpdb->prefix . "duendes";
if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
$sql = "CREATE TABLE " . $table_name . " (
id mediumint(9) NOT NULL AUTO_INCREMENT,
shape tinytext NOT NULL,
integrity tinytext NOT NULL,
length tinytext NOT NULL,
drone tinytext NOT NULL,
wood tinytext NOT NULL,
mouth tinytext NOT NULL,
rim tinytext NOT NULL,
bell tinytext NOT NULL,
loud tinytext NOT NULL,
mass tinytext NOT NULL,
finish tinytext NOT NULL,
inlay tinytext NOT NULL,
price smallint DEFAULT '0' NOT NULL,
sold tinytext NOT NULL,
UNIQUE KEY id (id)
);";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
add_option("duende_db_version", $duende_db_version);
}
}
Thank you
latin1_swedish_ci
. Wordpress sets the collation only for the connection, not for the database. E.g. forWHERE
orORDER BY
clauses.