RE: [PHP] counting clicks
| From: | Jay Blanchard | Date: | Wed, 29 Nov 2006 18:53:27 +0000 |
| Subject: | RE: [PHP] counting clicks | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-245298@lists.php.net to get a copy of this message | ||
[snip]
This has a race condition where a busy server, or even a not-so-busy
one where 2 people happen to click at the same time, at least one of
them will be "missed", at best.
There's also a distinct possiblity of the counter file getting
completely trashed, depending on the OS and its underlying atomicity
of fwrite().
And, finally, you'd need "w+" in that fopen() to avoid wiping out the
old data to start with.
For this reason, and more, you're almost-for-sure better off keeping
track in a database which solves all the nasty race condition issues.
[/snip]
Exactly, YMMV