Calling conn.end() to release a pooled connection is deprecated. In next version calling conn.end() will be restored to default conn.end() behavior. Use conn.re
我的代码:
exports.query = function(sql,data,callback){
var mym = false;
var mycallback;
var mydata;
if (typeof data === 'function'){
mycallback = data;
mydata = [];
}
else{
mycallback = callback;
mydata = data;
};
mym = sql.split(';').length > 1; //有多个sql了
pool.getConnection(function(err,conn){
if(!err){
config.debug || console.log(sql);
conn.query(sql,data,function(err,rows){
conn.end();
if(!err){
if(mycallback) mycallback(null,rows);
}
else{
if(mycallback) mycallback(err,null);
}
});
}
else{
if(mycallback) mycallback(err,null);
}
});
};