Problem:
The database encoding is utf8, and the Yii connection database encoding is also utf8, but the Chinese data retrieved is garbled.
Reason:
When entering the sql statement to insert Chinese data in the terminal, the environment is not utf8, so the data stored in the mysql database is not utf8 encoded, and the data taken out is garbled.
(Recommended tutorial:yii framework)
Solution:
When entering the sql statement to insert Chinese data in the terminal, you need to set the encoding first The environment is utf8, such as:
set names utf8
Just save the inserted data as utf8.
For more programming-related content, please pay attention to theProgramming Introductioncolumn on the php Chinese website!
The above is the detailed content of Chinese garbled characters appear when the yii framework accesses the database. For more information, please follow other related articles on the PHP Chinese website!