Answer the question
In order to leave comments, you need to log in
How to insert a record or update?
How to do INSERT INTO ON DUPLICATE KEY UPDATE ?
function userWin(val) {
return new Promise(function (resolve, reject) {
const win="UPDATE `user` SET `monets`= monets+? ,`exp`=exp+? WHERE `uid`=?";
const par = [val.gold,val.xp,val.user];
connection.query(win, par,
function(err, results) {
if (err) reject(err);
resolve(results);
});
connection.end();
//console.info(val)
})
}
Answer the question
In order to leave comments, you need to log in
Some strange request) Rebus for a drug addict)
function userWin(val) {
return new Promise(function (resolve, reject) {
const par = [val.gold,val.xp,val.user];
const win = `UPDATE user SET monets = ${par[0]},exp = ${par[1]} WHERE uid = ${par[2]}`;
connection.query(win, (err, results) => {
if (err) reject(err);
resolve(results);
});
connection.end();
}).then(r => {
console.log(r)
})
}
function userWin(val) {
return new Promise(function (resolve, reject) {
const par = [val.gold,val.xp,val.user];
let monets = par[0],
exp = par[1];
const win = `UPDATE user SET ? WHERE uid = ${par[2]}`;
connection.query(win, {monets,exp}, (err, results) => {
if (err) reject(err);
resolve(results);
});
connection.end();
}).then(r => {
console.log(r)
})
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question