Is there a way to get the last generated auto_increment IDs after inserting several rows with mysqli multi_query function?
EDIT:
I managed to get it work by adding SELECT LAST_INSERT_ID(); after each INSERT query in the multi query and then use the mysqli_use_result to get all ids, and I think this is the best way.
You can fetch the different insert ids by calling MySQLi's
next_result()
for each consecutive insert statement. As far as I know, you don't have to store any results as long as the queries are insert statements or something else that doesn't return a result set.You can also put this in a loop if you are unsure of how many insert statements there are:
This is untested pseudo code (as you might have figured), but it should work.