This is not just problem, but execute when every connect and it was somehow eyesore, so I fix to don’t execute that query.
the code execute query
SET NAMES foo
The case of codeigniter * mysqli, it is execute this code↓
This product use UTF-8 charset, and configure my.cnf too.
So I thought in the first place, this is not need it. comment out
set_charset() for now. Then, don’t execute
SET NAMES foo and don’t garbled.
Only one environment garbled characters
It' OK. just as planned. I apply other environment this fixing. one environment garbled characters. it seemed garbled by latin1.
There is difference in default charset by mysql library
The result i investigated, There is difference in default charset by mysql library.
|mysqlnd||the server default charset|
|libmysql||charset selected when build(latin1 if no selected)|
Finally, the cause of garbled is the server is used libmysql.
How to fix,
- use mysqlnd
- rebuild libmysql and select charset
- select charset by mysqli_options (selectable charset without
SET NAMES foo) PHP: mysqli::options - Manual
This is a minute thing, but it would be better a few query!