Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Each call on a PHP script is independent of the other scripts you have.
And yes, you can have 2 call that are so close, that the update will be with the same result, although it should not.
This is a known "flaw" caused by the way the display and the request are disconnected in the client/server model the web is built.
The only real way to avoid this, is by using semaphores, or lock.
If you update a db, lock the table you are working with when you update a value.
It will make every other queries against that table to wait for the lock to be released to complete.
That way, you can be sure that only 1 operation can be done in 1 table at a given time.
Otherwise, you can use a "file based" semaphore.
Have both script1 and script2 checking for the existence of a file when they run.
If the file exists, the must wait until the file is gone to work.
But this is less secure than a table lock, as again, 2 request can be so close that they occur at the same time, and both see the semaphore file as not being present.
__________________
Only a biker knows why a dog sticks his head out the window.
|