php counter using mysql
I'm trying to write a very simple hit counter in php. No data is stored other than the count itself. Several tutorials I've seen involve writing/reading from a data file. I can imagine this would break if two visits occur at the same time (they both read the same value from the data file and both write the same updated value).
I've also seen a similar approach using mysql, with the same problem (I assume...). Is there any other way other than adding another row to a table for each visit?
Locks are generally used to prevent concurrent updates. A locked object (file, table) cannot be read or written by another process, so one would lock the object, read/write the necessary data, and unlock it.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement