Is it safe to get ID through lastInsertId()? [duplicate]

霸气de小男生 提交于 2021-02-05 12:13:43

问题


I've a database with hundreds of records which inserted in each seconds, I have the below insert query and I want to know the insert id of this query:

   $currQuery = $pdo->prepare("INSERT INTO some_table (...... )");
   $currQuery->execute("....");
   $queryInsertId = $pdo->lastInsertId();

I just want to know that is it safe to use lastInsertId() while I having hundreds of new records in every seconds? any ideas?


回答1:


Yes it is safe. It returns the last insert id for the connection.



来源:https://stackoverflow.com/questions/25649905/is-it-safe-to-get-id-through-lastinsertid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!