【新手提问】请问nodejs的mysql模块为什么无法回滚?
按照github中mysql模块的wiki来的,不可用啊。mysql已经设置innodb autocommit也关闭了,代码贴下来,麻烦大家帮忙看看。 connection.beginTransaction(function (err) { if (err) { throw err; res.json({ success : false, err : err }); return ; }
var delete_sql = "delete from tp_lbs where type= ?";
// var delete_sql = 'insert into tp_lbs (name, address, phone, longitude, latitude, type) values (1,2,3,4,5,6)';
connection.query(delete_sql, [type], function (err, result) {
if(err) {
connection.rollback(function() {
throw err;
});
res.json({
success : false,
err : err
});
return ;
}
var sql = "sekect name from tp_lbs where ,.";
connection.query(sql, [], function (err, result) {
if(err) {
connection.rollback(function() {
throw err;
});
res.json({
success : false,
err : err
});
return ;
}
connection.commit(function(err) {
if (err) {
connection.rollback(function() {
throw err;
res.json({
success : false,
err : err
});
return ;
});
}
res.json({
success : false,
err : err
});
});
});
});
});