Reputation: 1
I use the cakephp with SQL server 2012. In my database I have declare nvarchar instead of varchar to show the unicode. But when I use
$this->set('types',$this->Manager->query('select * from product_types'))
the result is :
Array
(
[0] => Array
(
[0] => Array
(
[id] => 2
[name] => Th?c u?ng c� c?n
)
)
[1] => Array
(
[0] => Array
(
[id] => 3
[name] => B�nh k?o
)
)
[2] => Array
(
[0] => Array
(
[id] => 4
[name] => X� b�ng
)
)
[3] => Array
(
[0] => Array
(
[id] => 5
[name] => H�ng h�a d�ng h?p
)
)
)
It doesn't show unicode characters.
Upvotes: 0
Views: 322
Reputation: 2148
You should change your database setting in app/Config/database.php:
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'database_name',
'prefix' => '',
//'encoding' => 'utf8',
);
to:
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'database_name',
'prefix' => '',
'encoding' => 'utf8', //uncomment this line
);
Upvotes: 1