通过 lastInsertId() 获取 ID 是否安全? [英] Is it safe to get ID through lastInsertId()?

查看:37
本文介绍了通过 lastInsertId() 获取 ID 是否安全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库,每秒钟都会插入数百条记录,我有以下插入查询,我想知道此查询的插入 ID:

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();

我只想知道在我每秒钟有数百条新记录的情况下使用 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?

推荐答案

是的,它是安全的.它返回连接的最后一个插入 ID.

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

这篇关于通过 lastInsertId() 获取 ID 是否安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆