Php 使用Yii2将Android表情符号从Firebase保存到MySQL
我尝试将数据从Php 使用Yii2将Android表情符号从Firebase保存到MySQL,php,mysql,firebase,yii,yii2,Php,Mysql,Firebase,Yii,Yii2,我尝试将数据从Firebase导入MySQL数据库 我的Firebase数据如下所示: 现在,我尝试获取此记录并保存到MySQL: $model = new DbModel(); $wpath = "/messages/". $id; $wvalue = $firebase->get($wpath); $wjson = json_decode($wvalue, true); $model->message = $wjson["message"]; //th
Firebase
导入MySQL
数据库
我的Firebase数据如下所示:
现在,我尝试获取此记录并保存到MySQL:
$model = new DbModel();
$wpath = "/messages/". $id;
$wvalue = $firebase->get($wpath);
$wjson = json_decode($wvalue, true);
$model->message = $wjson["message"]; //this is ok, if I print it'll show the emoji
$model->save();
保存模型后,我在数据库中获得以下信息:
I'm going to dance ????
我在表中为我的列设置了排序规则,当我通过脚本或UI手动插入相同的文本时,排序规则似乎有效,但是当我通过php保存模型时,表情符号没有保存
我的服务器版本:10.1.16-MariaDB-MariaDB.org二进制发行版
Web服务器:Apache/2.4.23(Win32)OpenSSL/1.0.2h PHP/7.0.9
任何建议都将不胜感激。最终找到了解决方案
更改数据库连接设置中的字符集也很重要:
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=db',
'username' => 'root',
'password' => '',
'charset' => 'utf8mb4',
终于找到了解决办法
更改数据库连接设置中的字符集也很重要:
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=db',
'username' => 'root',
'password' => '',
'charset' => 'utf8mb4',