MasterKaos
Programmer
Ok, I know this is probably more of an Apache thing, but I'd like to hear how it relates to PHP specifically.
When the server gets several requests for a particular PHP file, does each PHP script get executed from beginning to end before the next one gets served? Specifically - if there is a file operation involved, can I rest assured that that the file will be opened, written to and closed before the next script tries to open it? Or is there a risk that before the first script closes the file the next script is allready trying to open it and failing? This is assuming of course that the file in question is only accessed by one particular script.
If the answer to the above question is that numerous instances of a particular script could be executing at the same time, and there is a risk that a file may be in use - would it be suficient to put the fopen() in a loop, say let it try a hundred times then give up, hoping that sooner or later the file will be free?
Would using MySQL instead of a flat file solve this problem? As I understand MySQL automatically handles locking so if two users try to insert or update a table simulataneously then MySQL will put one in a queue and wait till the first one has unlocked the table. Is this correct? Does this work when the same user (the one doing a connect in PHP) is doing both the inserts?
I guess thats a lot of questions for one post but hopefully you can see that it all relates to one issue, and perhaps if this isn't the right place to find the answers someone can point me in the right direction?
Thanks!
When the server gets several requests for a particular PHP file, does each PHP script get executed from beginning to end before the next one gets served? Specifically - if there is a file operation involved, can I rest assured that that the file will be opened, written to and closed before the next script tries to open it? Or is there a risk that before the first script closes the file the next script is allready trying to open it and failing? This is assuming of course that the file in question is only accessed by one particular script.
If the answer to the above question is that numerous instances of a particular script could be executing at the same time, and there is a risk that a file may be in use - would it be suficient to put the fopen() in a loop, say let it try a hundred times then give up, hoping that sooner or later the file will be free?
Would using MySQL instead of a flat file solve this problem? As I understand MySQL automatically handles locking so if two users try to insert or update a table simulataneously then MySQL will put one in a queue and wait till the first one has unlocked the table. Is this correct? Does this work when the same user (the one doing a connect in PHP) is doing both the inserts?
I guess thats a lot of questions for one post but hopefully you can see that it all relates to one issue, and perhaps if this isn't the right place to find the answers someone can point me in the right direction?
Thanks!