Advertisement Jump to content
Sign in to follow this  
Prozak

MySQL Query Sync Question/ Issue

This topic is 4965 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 build a small website, and this issue has plagued my mind. I have the following steps: 1) Check if a certain item already exists in the DB 2) If not, then insert new item As you can guess, between steps 1 and 2, there might be some other thread running the same query, and both run step 1, and in truth there is no such item on the DB, and then both execute step 2, inserting 2 equal items on the DB, and therefore currupting it's contents with invalid data... How can I solve this issue between multiple threads running on the server? (I'm using wamp: windows, apache, php4 and mysql). Thanks for any tips on this.

Share this post


Link to post
Share on other sites
Advertisement
The EXISTS clause (or rather, NOT EXISTS) will allow you to make it a single query.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!