• Advertisement
Sign in to follow this  

Updating a mySQL Table...

This topic is 4148 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've got a FILES table in mySQL, on my site, which I'm accessing using PHP. Now, the FILES table has a "downloads" field. Each time someone downloads the file, this entry should be incremented. Thing is, there isnt an mysql_field_increment("downloads"), is there? So, I guess that I need to do a Select, to know what is the current value of the field, let's say 1234, increment it using PHP code, and then do an Update on the table. But... another thread could be doing the exact same thing at that exact same time, so I need some way to lock tables, and I have zero experience with that... Anyone with experience with this sort of thing?

Share this post


Link to post
Share on other sites
Advertisement
Thanks for the reply, its working, rating++ [wink]

If I wanted to achieve the same result but with "mutexes", or table locking, how would I go about it?

Share this post


Link to post
Share on other sites
If databases didn't perform statements atomically by default, there'd be little point them existing. Each UPDATE should run atomically without needing any further intervention.

Share this post


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

  • Advertisement