1

I have a separate connection to connect to another DB with this code of line:

$wpdb = new wpdb(STATYBA_USER, STATYBA_PASS, STATYBA_DB, STATYBA_HOST);

and it has another DB charset (latin1 instead of utf8), so how can I change the charset without changing DB_CHARSET constant in wp_config.php?

3

You can try the wpdb set_charset method (more info here).

example use:

$statyba_wpdb = new wpdb(STATYBA_USER, STATYBA_PASS, STATYBA_DB, STATYBA_HOST);
$statyba_wpdb->set_charset($statyba_wpdb->dbh, 'utf8');

Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.