asmith Posted August 14, 2009 Share Posted August 14, 2009 Hi, With a single query I'm inserting multiple rows into a table. mysql_insert_id() or LAST_INSERT_ID() in the mysql returns the FIRST row id. I want to store the IDs of the inserted rows by the query in an array. I know how many rows it will be insert and I have the first inserted id, so I guess I can have all the IDs myself. I just doubt it that in a busy server, Is it possible that 2 users running the script have a conflict in inserting the rows? So that one's rows insert in the middle of another's rows... (or MySQL locks it when inserting one's row?) Is there any other way to get all the IDs of that single query? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/170238-last_insert_id-on-multiple-rows/ Share on other sites More sharing options...
fenway Posted August 21, 2009 Share Posted August 21, 2009 As you've discovered, multi-valued inserts will only return the first auto-increment value -- that's for replication -- but if you need the actual IDs for each one, you'll have to run each separately. Quote Link to comment https://forums.phpfreaks.com/topic/170238-last_insert_id-on-multiple-rows/#findComment-903189 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.