Jump to content
  • Advertisement
Sign in to follow this  
Daniel Miller

php counter using mysql

This topic is 4252 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Thanks for the response, I think I'm just going to add rows to a table. That way, I can use an auto-incrementing field to keep count, and I can periodically clear the table to keep if from getting ridiculously big.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!