随笔 - 124  文章 - 3  评论 - 5  阅读 - 18万

关于四字节字符入库时错误的解决方案(Incorrect string value: '\xF0\x9F\x99\x8F' for column 'Reply_Content' at row 1)

1. 将表字段字符集设置成utf8mb4
2. 执行插入前执行:SET NAMES utf8mb4;
如:
SET NAMES utf8mb4;
INSERT test(Content) VALUES('~');

PHP例子:
$paramValues=array('Content'=>'~');
$dbCommand->query('SET NAMES utf8mb4');
$lastInsertID=$dbCommand->insertOne('test',$paramValues);

posted on   思静  阅读(17830)  评论(0编辑  收藏  举报
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

点击右上角即可分享
微信分享提示