0

i want to store urdu word in database and in the database they should store ???????? this value In yii database connection charset =>'utf8' table type is utf8_general_ci
using Yii framework php

2 Answers2

0

Your main.config file should be like this:

'components' => array(
    ...
    'db' => array(
        ...
        'charset' => 'utf8',
        'initSQLs'=>'SET NAMES utf8 ;',
    ),

),
hamed
  • 7,939
  • 15
  • 60
  • 114
  • 'db' => array( 'connectionString' => 'mysql:host=localhost;dbname=e_promotion', 'emulatePrepare' => true, 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', 'schemaCachingDuration' => 1, ), – Bilal Islam Mar 16 '15 at 09:52
  • sir my db connection setting – Bilal Islam Mar 16 '15 at 09:53
  • Follow [this documentation](http://www.yiiframework.com/wiki/16/how-to-set-up-unicode/). Hope this help you. – hamed Mar 16 '15 at 10:06
0

MySQL's 'utf8' is a 3-byte lie. Use utf8mb4 instead for all your settings (both table definitions and connection settings) if you want to correctly handle all UTF-8 characters.

See documentation.

Willem Renzema
  • 5,177
  • 1
  • 17
  • 24