Answer the question
In order to leave comments, you need to log in
Mysql how to know query conditions when responding?
I make a request:
'SELECT * FROM `Method_Arguments` WHERE `id` = "1"'
mysql_connection.query('SELECT * FROM `Method_Arguments` WHERE `id` = "1010" ', function(err, result) {
if (err){
err=null;result=null; console.log(" Get err"); return;
};
if(result.length > 0)
{
}else{
console.log(' тут выводим ид из WHERE `id` = "1010" ' );
}
})
Answer the question
In order to leave comments, you need to log in
if there are no matches - get an empty answer.
redirect the response to a variable, parse it - and return the response depending on the content.
And, by the way, what is the meaning of the task?
And why through the closure is not satisfied?
// Экспрессовский app.get() приведён для демонстрации контекста потока
app.get('/users/:id', function (req, res, next) {
var id = req.params.id|0; // /users/1010 -> id = 1010;
mysql_connection.query("SELECT * FROM `Method_Arguments` WHERE `id`=?", [id],
function (err, result) {
if (err) return next(err);
if (result.length > 0) {
console.log(result);
} else {
console.log(id); // тут выводим id из WHERE
}
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question