Operating Environment: SAE + thinkphp
Db_charset is UTF8; (directly set to UTF8MB4 will be an error, I do not know why ...) )
To support the emoji expression, the test code is as follows
Public Function test () {
$model = M(''); $model -> query('set names utf8mb4');}
Error message: [SQL statement]: set names UTF8MB4.
Ask the great God for some guidance, thank you!
Reply content:
Operating Environment: SAE + thinkphp
Db_charset is UTF8; (directly set to UTF8MB4 will be an error, I do not know why ...) )
To support the emoji expression, the test code is as follows
Public Function test () {
$model = M(''); $model -> query('set names utf8mb4');}
Error message: [SQL statement]: set names UTF8MB4.
Ask the great God for some guidance, thank you!
select version(); 看下数据库版本,5.5以上才支持utf8mb4
Mysql::utf8mb4
1, check the version of MySQL;
After MySQL 5.5.3 version, add utf8mb4 character set; the previous version should upgrade MySQL server first.
2. MySQL UTF8MB4 Character Set
Modify/ETC/MY.CNF
[Client]
Default-character-set = Utf8mb4
[MySQL]
Default-character-set = Utf8mb4
[Mysqld]
Character-set-client-handshake = FALSE
Character-set-server = Utf8mb4
Collation-server = Utf8mb4_unicode_ci
init_connect= ' SET NAMES utf8mb4 '
Restart MySQL Server, check the character set