没有显示任何错误,但重新发现仍然没有更新.. 在我的快递函数下面删除。
waitingModel.delete = function(id,callback) {
db.getConnection(function(err, connection) {
var sql = 'UPDATE customers_ariving SET deleted = 1 WHERE id='+id;
console.log(sql);
connection.query(sql,function(err,data) {
var result = {};
if (err) {
connection.release();
callback(err, null);
} else {
connection.release();
result = data;
callback(null, result);
}
});
});
};
答案 0 :(得分:0)
我找到了来自ref link的解决方案:Node.js mysql query syntax issues UPDATE WHERE
我想更新列deleted = 1,所以我直接添加了值。
waitingModel.delete = function(id,callback) {
db.getConnection(function(err, connection) {
var sql = 'UPDATE customers_ariving SET deleted = ? WHERE id = ?';
connection.query(sql, ['1',id],function(err,data){
var result = {};
if (err) {
connection.release();
callback(err, null);
} else {
connection.release();
result = data;
callback(null, result);
}
});
});
};