Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/69.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
Mysql Rails,将奇怪的字符串插入数据库。如何逃避一切?_Mysql_Sql_Ruby On Rails_String_Escaping - Fatal编程技术网

Mysql Rails,将奇怪的字符串插入数据库。如何逃避一切?

Mysql Rails,将奇怪的字符串插入数据库。如何逃避一切?,mysql,sql,ruby-on-rails,string,escaping,Mysql,Sql,Ruby On Rails,String,Escaping,有时我不得不在db中插入一些奇怪的东西,例如: SET `title` = '\"- ✪㉨)⊃ [PC] 1# Potato(ง ͠ ᵒ̌ Дᵒ̌)\"' 错误: Mysql2::Error: Incorrect string value: '\xE2\x8A\x82(\xE2\x9C...' for column 'title' at row 1 我的ActiveRecord代码: @title = "- ✪㉨)⊃ [PC] 1# Potato(ง ͠ ᵒ̌ Дᵒ̌)\" User.up

有时我不得不在db中插入一些奇怪的东西,例如:

SET `title` = '\"- ✪㉨)⊃ [PC] 1# Potato(ง ͠ ᵒ̌ Дᵒ̌)\"'
错误:

Mysql2::Error: Incorrect string value: '\xE2\x8A\x82(\xE2\x9C...' for column 'title' at row 1
我的ActiveRecord代码:

@title = "- ✪㉨)⊃ [PC] 1# Potato(ง ͠ ᵒ̌ Дᵒ̌)\"

User.update(1, title: "#{@title.inspect}") # .inspect doesn't help :/ 

我想我能做的是,我可以用wierdo符号创建一个表,比如
并在保存之前用一些代码替换字符串中的代码。并在从数据库中选择此字符串后用这些符号替换一些代码。但是基本上不可能捕捉到所有的东西……

这似乎是一个问题。对于数据库和表,您使用了哪些排序规则?您是否尝试过unicode。从latin1改为utf-8,它似乎可以工作。谢谢大家:)