Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 Eloquent charset utf8 issues

I use Laravel 5.1 and a mysql server. I have a database with table in utf8 unicode, and my databse configuration file is like this :

'mysql' => array(
'driver'    => 'mysql',
'host'      => 'localhost',
'database'  => 'database',
'username'  => 'root',
'password'  => 'password',
'charset'   => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix'    => 'false',
),

But when I use queries from eloquent, my texts which have accents are broken. It's not a problem from blade because I can write accent in the views correctly, and if I use PDO directly my text is nice.

How can I solve my problem with my queries from eloquent ?

like image 430
EkinOf Avatar asked Sep 27 '22 16:09

EkinOf


1 Answers

I found my problem, I hope it will help others :

My Mysql databases are encoded in latin1 by default. I was sure that my databases were in utf8 so I configured as that in the configuration file on my laravel project.

like image 104
EkinOf Avatar answered Sep 30 '22 08:09

EkinOf