Jump to content

roboBen

Members
  • Posts

    2
  • Joined

  • Last visited

roboBen's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Thanks for responding! Wouldn’t you have to create the function to stop the original function until it’s finished? Similar to for-loop or multiple functions of fs? Could you explain to me again what these functions are for? If I go through this with sample numbers, it doesn’t make sense. But I’m the one who asks for help in the forum... Thank you for your efforts and your time and I hope to get another answer from you.
  2. Hey guys, I need your help with a problem I’ve been able to walk around so far. Namely, I want to make a mysql query in a node.js web socket: connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results, fields) { if (error) throw error; // Code here... }) In the variable results I can now use the data in the form of a JSON object. That’s not a problem. So far, I have done this so that when I wanted to make several queries, I have nested into each other. Like this: connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results, fields) { if (error) throw error; connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results, fields) { if (error) throw error; // Code here... }) }) But now I need that some queries are only carried out if certain conditions are met. As a result, the queries can no longer be logically nested. That’s why I need something like this: if(a == b) { connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results1, fields) { if (error) throw error; // Code here... }) } if(c == b) { connection.query("SELECT * FROM DB WHERE id= ?;", [id], function(error, results2, fields) { if (error) throw error; // Code here... }) } And after both if loops I can logically no longer access the values results1 and results2. How can I do that? Do you need more information. I hope for some answers. Yours, Ben
×
×
  • Create New...