Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Yii2将Android表情符号从Firebase保存到MySQL_Php_Mysql_Firebase_Yii_Yii2 - Fatal编程技术网

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',