'Is using $wpdb->get_charset_collate() necessary when creating tables in WordPress?
When creating tables in WordPress, is it necessary to use $wpdb->get_charset_collate()
?
Wouldn't the default charset automatically be used?
Example:
$charset_collate = $wpdb->get_charset_collate();
$my_sql = "CREATE TABLE $my_table_name (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(50) NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
dbDelta( $my_sql );
When is using $wpdb->get_charset_collate()
helpful vs. not?
Solution 1:[1]
If you don't set one collation, the database will use the default collation, if all data use the iso encode for text there is no problem, but if you use the UTF-8 encode you must to change the encode before save data in database. That why is prefered to set the collation, wordpress by default set the UTF-8 collation.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | user18931037 |