Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

json格式字符串插入mysql报错

$
0
0

两种写法结果不同: 第一种: var sql = "INSERT INTO table1 SET ?"var messageArr = [{messsage1:"as a message"},{messsage2:"as a message"}];var value = [{message:JSON.stringify(messageArr)}];conn.query(sql, value, function(result){.......})第二种: var sql = "INSERT INTO table1 SET message = ? "var messageArr = [{messsage1:"as a message"},{messsage2:"as a message"}];var value = [JSON.stringify(messageArr)];conn.query(sql, value, function(result){.......})其中第二种成功,第一种报错: Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''[object Object]'' at line 1貌似是被认作json对象了 这两天突然报错,之前的代码都不能用了,不知道是不是配置被改动了. 求解应该怎么解决


Viewing all articles
Browse latest Browse all 14821

Trending Articles