1

PHP - > Inserts VALUE into MySql database on FILE1.php

-- Success: Redirects to FILE2.php?ID=(Last_Id) --

PHP - > Requires (Last_Id) to work fine.

Question:

Should PHP sleep 1 second before redirecting, when the mentioned database contains 100k+ rows, to avoid any possible problem, or is that in-necessary?

I tried it and it works fine without sleeping, which doesn't really mean it will always work.

Thanks for any information you may throw in, and for taking your time.

Nikau
  • 51
  • 8

1 Answers1

1

No, you shouldn't sleep. Your call is synchronous.

Dmitry V.
  • 336
  • 4
  • 11
  • This. Remember that PHP is a Blocking I/O language, in other words, your script won't get to the redirect until the insert operation is done. This model is completely different from languages like Node.js where you can have multiple processes running at the same time. – Guillermo Mansilla May 31 '15 at 13:07
  • With a little hoop jumping you could achieve async mysql calls. Here is an [article](http://blog.ulf-wendel.de/2012/non-blocking-insert-with-mysqlnd/) – Dmitry V. May 31 '15 at 13:16
  • Thank you very much. Peace :) – Nikau May 31 '15 at 13:48