Mysql 在NodeJS中的准备好的查询中设置多个字段
我正在节点中使用“mysql”库 这是我用来代替事先准备好的陈述的方法,效果很好:Mysql 在NodeJS中的准备好的查询中设置多个字段,mysql,node.js,express,prepared-statement,Mysql,Node.js,Express,Prepared Statement,我正在节点中使用“mysql”库 这是我用来代替事先准备好的陈述的方法,效果很好: connection.query("update table set col1=? where col2=1",[val1],function(err,rows){ //connection.release(); if(!err) { //further code } }); 但是,这不适用于两种未知情况: con
connection.query("update table set col1=? where col2=1",[val1],function(err,rows){
//connection.release();
if(!err) {
//further code
}
});
但是,这不适用于两种未知情况:
connection.query("update table set col1=? where col2=?",[val1],[val2],function(err,rows){
//connection.release();
if(!err) {
//further code
}
});
错误消息显示“未定义不是函数”。我做错了什么?您需要在单个数组中定义值,如下所示:
connection.query("update table set col1=? where col2=?",[val1,val2],function(err,rows){
//connection.release();
if(!err) {
//further code
}
});
所有必要的功能都可以在这里轻松找到:非主题:您知道PostgreSQL的任何类似完整模块吗?别忘了标记答案。我想,您可以使用类似的东西。我的两个更新值中有逗号(,),这会搞乱查询。我该怎么做才能摆脱它?你确定你正在使用我提供的功能吗?库应将值转义为。