Running environment: sae + thinkphpDB_CHARSET is utf8; (setting utf8mb4 directly causes an error. I don't know why ...) To support emoji expressions, the test code is as follows: publicfunctiontest () {code...} error prompt: [SQL statement]: setnamesutf8mb... running environment: sae + thinkphp
DB_CHARSET is utf8; (if you set it to utf8mb4 directly, an error is returned. I don't know why ...)
To support emoji expressions, the test code is as follows:
Public function test (){
$model = M(''); $model -> query('set names utf8mb4');}
Error message: [SQL statement]: set names utf8mb4.
Thank you for your guidance!
Reply content:
Running environment: sae + thinkphp
DB_CHARSET is utf8; (if you set it to utf8mb4 directly, an error is returned. I don't know why ...)
To support emoji expressions, the test code is as follows:
Public function test (){
$model = M(''); $model -> query('set names utf8mb4');}
Error message: [SQL statement]: set names utf8mb4.
Thank you for your guidance!
Select version (); check the database version. utf8mb4 is supported only in versions later than 5.5.
Mysql: utf8mb4
1. check the mysql version;
For versions later than mysql 5.5.3, the utf8mb4 character set is added. for previous versions, you must upgrade mysql server.
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 and check character set