Is there an easy way of getting the charset and collation of the DB tables in WordPress without resorting to SQL queries?
Leave a Reply
You must be logged in to post a comment.
Is there an easy way of getting the charset and collation of the DB tables in WordPress without resorting to SQL queries?
You must be logged in to post a comment.
There are
$wpdb->charset
and$wpdb->collate
. I am not sure if or when one of these values might be empty, so it is better to prepare for empty values â¦From my DB class:
Used to create a table like this:
Related: Problem with blog charset UTF-7
The file
wp-admin/includes/upgrade.php
includeswp-admin/includes/schema.php
. This at the top declare as global (see source):So you can follow @Toscho’s answer and check
$wpdb
. Or, using Toscho’s example:Note the
IF NOT EXISTS
is not required asdbDelta()
handles this.