connection.query(
'select * from book where author = "xyf" and country = "china"',
function(err, result) {
console.log(result);
}
);
connection.query(
'select * from book where author = ? and country = ?',
['xyf', 'china'],
function(err, result) {
console.log(result);
}
);
connection.query(
{
sql: 'select * from book where author = ? and country = ?',
values: ['xyf', 'china'], // 作为对象的属性
timeout: 40000,
},
function(err, result) {
console.log(result);
}
);
connection.query(
{
sql: 'select * from book where author = ? and country = ?',
timeout: 40000,
// ['corner', 'us'] // 如果同时设置,那么此时不会生效
},
['xyf', 'china'], // 作为query函数的一个参数
function(err, result) {
console.log(result);
}
);
var username = 'xyf'; var sql = 'select * from book where author = "'+username+'"';
var username = '"1 or 1=1'; var sql = 'select * from book where author = "'+username+'"';
select * from book where author = "" or 1=1
var authorname = 'user input';
connection.escape(authorname);
// 或者使用mysql.escape(authorname);
connection.query(
'select * from book where author = "'+authorname+'"',
function(err, result) {
console.log(result);
}
);
let connection = mysql.createConnection({
// 其他配置
multipleStatements: true,
});
connection.query(
{
sql: `select * from book where username = ?;
select * from book where username = ?;`,
},
['ace','xyf'],
function(err, rows, fields) {
if (err) throw err;
console.log('The solution is: ', rows);
}
);
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有