1

Does PDO::lastInsertId() returns last inserted id among all the tables in database? or from a specific table currently it working on?

I have a doubt like if multiple users working on website and they try to execute some same kind of a operation and which effects to the same tables in the database. Then if it happens at the same time will PDO lastInsertId handle that? Will POD lastInsertId return lastInsertedId for relative users. I mean like will it return correct row id to the correct person who inserted that row? or will it mixed up? like the id of row I inserted will return to someone else, and I will get a row id which is not from the row I inserted.

Kasun
  • 672
  • 8
  • 18
  • 3
    It returns the last inserted id for the specific connection you're calling it on. So even if 1000 users insert something at the same time, each user will get the id they inserted using that connection. – M. Eriksson Oct 22 '21 at 05:44

0 Answers0