嗨,我正在一個小項目上工作,我卡住了。我想要做的是比較具有可變的MySQL行從數據庫中獲取(功能winner_daily)用戶steamid(SRY,我的英語:()。在這裏我的代碼 節點mysql變量比較
var mysql = require('mysql');
var pool = mysql.createPool({
connectionLimit : 10,
host : 'localhost',
user : 'root',
password : '*****',
database : 'bet'
});
pool.query("SELECT `name` FROM `users` WHERE levels >= 3 ", function (error, results, fields) {
if (error) throw error;
var rand = results[Math.floor(Math.random() * results.length)];
winner_daily(rand);
});
function winner_daily(winner){
console.log("And the winner is :",winner);
pool.query(`SELECT steamid FROM users WHERE name = ${mysql.escape(winner)}`, function (error, row, fields) {
if (error) throw error;
console.log(row)
});
}
很清楚自己想要做什麼,但什麼是你與現在的代碼有問題?應該發生什麼情況,什麼? – tima