0
Wenn ich diese Funktion ausführen, bekomme ich null, wenn es zurückkommt, weil ich die Rückkehr innerhalb der MySQL-Abfrage habe, wie kann ich das lösen?Javascript Mysql innerhalb Funktion
function CheckStorage(Host, Slots, SSLocation) {
connection.query("SELECT * FROM `machines` WHERE `shost` LIKE '" + Host + "' AND `location` LIKE '" + SSLocation + "' AND `slotsa` >= " + Slots + "", function(err, rows, fields) {
if(rows[0]) {
console.log(rows[0]["ip"]);
return rows[0]["ip"];
} else {
return false;
}
});
}
Die Funktion ist async .. Callbacks ist die Antwort. –
Mögliches Duplikat von [Wie gebe ich die Antwort von einem asynchronen Anruf zurück?] (Http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) –