Jump to content

Recommended Posts

hi, i used to develop desktop application before, and know that for networking application, we need to concern and control about the multiple access of users at the same time. now, this is the first time i'm developing website that will access MySQL database. so, i have several questions here regarding the multiple access to database. hope you guys that have experience can give some guidance.

 

1. for a website that connect to database, what special code we need to concern(i meant what code is needed) to allow it for multiple access at the same time?

 

2. in a case that i will get a serial number from table A, plus one to that serial number, then use the new serial number to insert a new record to another table, then the new serial number will be updated to table A. if so coincidence that 2 users perform the same thing at the same time, getting the same serial number from table A, plus one to it to insert a new record...what will happen? let's say user1's internet connection is faster and successfully insert the new record, and user2 then trying to insert the same serial number as primary key in that table again, isn't that error will occur? how can we solve this problem?

Link to comment
https://forums.phpfreaks.com/topic/153432-multiple-access-to-database/
Share on other sites

In the case of adding one to the serial number, you would let MySQL handle that. This isn't something you would do in PHP.

 

User #1 and User #2 click on "add 1 button"

 

MySQL will process one first, and "auto increment" the value, and will also "auto increment" the second transaction. Try it, and you will see that it works. You must of course set the serial number column of the table to auto increment.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.