This seems an old question but i didn't find any correct solution to my problem.I will explain the problem i am facing.
In my code part i have checked the table before inserting, whether the table has already has the value for the particular column.
select vid from mytable where vid=$vid;
if the vid value is not there then i have to execute the insert query in mytable else there is no need to insert.
But the the problem is in some how, in some scenario there is synchronous requests has been sent to the application and the above code has been executed more than one time. So there are some duplicate entries for the same vid. How can i prevent with this problem. Can i use begintransaction and endtransaction methods or is there any lock methods available?.
There is no constraints set for vid in during table creation except key.the table has 5 million records. So constraint update is not possible.
synchronous requests has been sent to the applicationDo you mean Asynchronous request?vidtouniqueso that it won't duplicate.https://stackoverflow.com/questions/11541171/how-to-lock-tables-with-codeigniter?lq=1..