I want to use PHP and MySQL to insert data into a data table and its many-to-many table. Automatically increasing the primary data table identifier is used in many tables. So, I need to know the identifier of the data table to insert into the many-to-many table.
My current thinking is that the best way to approach this is with a loop that will first be inserted into the data table and then use mysql_insert_id () to insert into the many-to-many table. Is this the best way to do this?
Also, do I need to worry about getting the wrong id with this function? Many workers will use this script data at the same time, so I am concerned that the identifier from one work request will be returned in the mysql_insert_id () call of the other. Is this a serious problem, and if so, how can I deal with it?
source
share