A
A
axeax2014-01-16 08:11:53
MySQL
axeax, 2014-01-16 08:11:53

Does the correct request manage to be sent to the engine in my case?

There is a piece of code in nodejs. Approximately it looks like this:

mysql.query('SELECT * FROM table WHERE id = '+arr[i]+';',  function(err, res){...});
delete arr[i];

The essence of the question: does the correct request have time to be transmitted to the engine? For some reason, every other time I get a zero execution result (the desired string is 100%, I tried to select the same ID.) There is a feeling that the array element is deleted earlier and undefined goes into the request. If after the request to remove delete arr[i]; then everything is fine. When placed delete arr[i]; the same thing happens in callback.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vit, 2014-01-16
@axeax

It shouldn't work, because you can't write like that.
If the deletion is not in the callback, then it will work before the request and arr[i] will be undefined.
If in a callback, then by the time the callback is called, a[i] will not be what you would like at all, and "foreign" data will be beaten.
In general, you can not do the same as yours.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question