user2131876
user2131876

Reputation:

How can I change DB charset in Yii DB management system

Can someone tell me how to set the DB charset from, let's say, utf-8 to latin2 or something like this?

Tried to google it but found nothing that could help... Also, I tried this method but for some reason this does not work for me...

P.S: I also tried to change it from main.php file under 'charset' which was default to utf-8 but it still does not work... I forgot to mention.

L.E: as you asked, this is the db setting:

'db' => array(
        'connectionString' => 'mysql:host=localhost;dbname=dbname',
        'emulatePrepare' => true,
        'username' => 'user',
        'password' => 'pass',
        'charset' => 'latin2',
        'initSQLs'=>'SET NAMES latin2;'
        'tablePrefix' => '',
        //'enableParamLogging' => true,
        //'enableProfiling'=>true,
    ),

Any ideas? Thanks...

Upvotes: 5

Views: 3791

Answers (1)

DarkMukke
DarkMukke

Reputation: 2489

What you are looking for is 'charset=utf8mb4'

which would result in

'db' => array(
        'connectionString' => 'mysql:host=localhost;dbname=dbname',
        'emulatePrepare' => true,
        'username' => 'user',
        'password' => 'pass',
        'charset' => 'utf8mb4',
        'initSQLs'=>'SET NAMES latin2;'
        'tablePrefix' => '',
        //'enableParamLogging' => true,
        //'enableProfiling'=>true,
    ),

Upvotes: 3

Related Questions