简体   繁体   English

FreeTDS UTF-8插入mysql

[英]FreeTDS UTF-8 insert in mysql

I have a linux server with mysql with symfony framework installed. 我有一个安装了symfony框架并带有mysql的linux服务器。 Now i'm trying to get data from sql server 2012 and all works great except when i try to insert value in mysql database. 现在我正在尝试从sql server 2012中获取数据,并且所有工作都很好,除非我尝试在mysql数据库中插入值。

SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\x80 IN P...' for column 'note_anagrafica' at row 1 

Seems that the problem is on data conversion. 似乎问题出在数据转换上。

The data type of column inside mysql where i'm trying to insert the data is: 我试图在其中插入数据的mysql内部列的数据类型是:

text

And the collation is: 排序规则是:

utf8_unicode_ci

FreeTds configuration is set on UTF-8 and driver is odbc. FreeTds配置在UTF-8上设置,驱动程序是odbc。

Someone have a solution for this problem? 有人对此问题有解决方案吗?

EDIT: 编辑:

odbc.ini odbc.ini

[server]
Driver = FreeTDS
Server = x.x.x.x
Port = 1234
Database = databasename
TDS_Version = 8
client charseg = UTF-8
server charset = CP1252

freetds.conf freetds.conf

[server]
     host = x.x.x.x
     port = 1234
     tds version = 8.0
     client charset = UFT-8
     text size = 20971520
     use uft-16 = true

doctrine config for mysql. mysql的教义配置。

charset: utf8mb4
          default_table_options:
              charset: utf8mb4
              collate: utf8mb4_unicode_ci

doctrine config for external mssql database: 外部mssql数据库的学说配置:

server:
          driver_class: Lsw\DoctrinePdoDblib\Doctrine\DBAL\Driver\PDODblib\Driver
          host:     "%a_database_host%"
          port:     "%a_database_port%"
          dbname:   "%a_database_name%"
          user:     "%a_database_user%"
          password: "%a_database_password%"
          charset:  utf8mb4

from now i'm getting error when i'm trying to insert data to mysql comes from sql server 2012 with doctrine. 从现在开始,当我尝试向mysql插入数据时出现错误,该错误来自sql server 2012。 Till now i have no problem on reading execpt that if i out the result on the web the special charaters like ø comes with symbol. 到现在为止,我在阅读execpt时都没有问题,如果我在网络上显示结果,像ø这样的特殊字符就会带有``符号。 There is a conversion that i have to made before call 致电前我必须进行一次转换

$entityManager->persist($object);
$entityManager->flush();

将字符集设置为utf8mb4进行教义配置,即可完成操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM