![](/img/trans.png)
[英]Node.js MYSQL to detect the INSERT/UPDATE completeness of a Query?
[英]Node.js mysql query insert arrays but it gives weird \\“something”\\
我正在尝试在nodejs中进行查询
我有 arrays 指令_0 和指令_1 和指令_2 和纬度_0 和纬度_1,纬度_2
var AddPlaceUsed =
"INSERT INTO most_places_used (instructions_0, instructions_1, instructions_2, place_name, dest_place_name, routePathIndex_0, routePathIndex_1, latitude_0, longitude_0, dest_latitude_0, dest_longitude_0, latlngs_0, latlngs_1, latlngs_2, mintues_between_0, distance_between_0, mintues_between_1, distance_between_1, mintues_between_2, distance_between_2, user_created,created_at) VALUES ?";
connections.query(AddPlaceUsed, [JSON.stringify(instructions_0),JSON.stringify(instructions_1),JSON.stringify(instructions_2),place_name,dest_place_name,routePathIndex_0,routePathIndex_1,latitude_0, longitude_0, dest_latitude_0, dest_longitude_0, JSON.stringify(latlngs_0), JSON.stringify(latlngs_1), JSON.stringify(latlngs_2), mintues_between_0, distance_between_0, mintues_between_1, distance_between_1, mintues_between_2, distance_between_2, user_created,now_place], function (err, result) {
console.log(err);
});
每当我尝试插入它们时,它都会在 MySQL 中出现错误,即
errno: 1064,
sqlMessage: `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 ''[[{\\"compassDirection\\":\\"west\\",\\"details\\":[{\\"compassDegrees\\":253,\\"endPath' at line 1`,
sqlState: '42000',
index: 0,
它给出了奇怪的 arrays 而不是我试图插入太多 \"\"\ 的东西,比如我希望有人能知道如何帮助它
I kept the query the same But I changed in MySQL all of the arrays to Longtext instead of JSON and every time I get the column in NodeJS I use JSON.parse(The value of the column -- array) and everything works so perfect. . 不会成为正确答案,因为它的解决方法而不是答案,但它有相同的目的,所以任何人都需要它,它是 <3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.