maybe_convert_table_to_utf8mb4()
If a table only contains utf8 or utf8mb4 columns, convert it to utf8mb4.
No Hooks.
Return
true|false
. True if the table was converted, false if it wasn't.
Usage
maybe_convert_table_to_utf8mb4( $table );
- $table(string) (required)
- The table to convert.
Examples
#1 Change the encoding of all table fields to utf8mb4
register_activation_hook( __FILE__, 'myplugin_activate' ); function myplugin_activate() { $table = 'my_table'; require ABSPATH . '/wp-admin/includes/upgrade.php'; maybe_convert_table_to_utf8mb4( $table ); }
Notes
- Global. wpdb. $wpdb WordPress database abstraction object.
Changelog
Since 4.2.0 | Introduced. |