What will happen in this case ?
If 2 concurrent users are using the same web application almost at the same time and both are inserting Data in a trans. table.
I am using the mysql_insert_id() to get the last id inserted to use it later on to save in another trans. table. (ref. table).
Suppose Last autoincrement value is 1002.
1st user inserts a row in the trans.table
1.$theSQL = "insert into...." ;
2.$resultSQL = mysql_query($theSQL, $linkdb);
3.$transid = mysql_insert_id() ;
if at a time gap of a fraction of a second another user inserts a row in the table just after point 2.
what will i get the transid for the 1st user?
1003.
or
1004.
if i get 1003, that is fine and safe.
But if i get 1004, my DB will be completely out of sync, with one table having a diff. trans.id then the other one.
Come on, put ur thinking caps on, and tell me what will be the result in concurrent users Insert SQL.
i am a bit concerned about this type of senario.
Thank you.
Brij.
If 2 concurrent users are using the same web application almost at the same time and both are inserting Data in a trans. table.
I am using the mysql_insert_id() to get the last id inserted to use it later on to save in another trans. table. (ref. table).
Suppose Last autoincrement value is 1002.
1st user inserts a row in the trans.table
1.$theSQL = "insert into...." ;
2.$resultSQL = mysql_query($theSQL, $linkdb);
3.$transid = mysql_insert_id() ;
if at a time gap of a fraction of a second another user inserts a row in the table just after point 2.
what will i get the transid for the 1st user?
1003.
or
1004.
if i get 1003, that is fine and safe.
But if i get 1004, my DB will be completely out of sync, with one table having a diff. trans.id then the other one.
Come on, put ur thinking caps on, and tell me what will be the result in concurrent users Insert SQL.
i am a bit concerned about this type of senario.
Thank you.
Brij.