sách gpt4 ai đã đi

php - mysql_insert_id 使用安全吗?

In lại 作者:行者123 更新时间:2023-11-30 22:41:26 25 4
mua khóa gpt4 Nike

根据 PHP 文档,mysql_insert_id 从 mysql 表中获取最后插入的 id。

我的问题是,如果我有一个每秒向数据库插入超过 2 行的网站,我可以使用 mysql_insert_id 并获得我在 中引用的正确 ID INSERT 查询前一行?

1 Câu trả lời

来自 MySQL 手册:

The ID that was generated is maintained in the server on a per-connection basis. This means that the value returned by the function to a given client is the first AUTO_INCREMENT value generated for most recent statement affecting an AUTO_INCREMENT column by that client. This value cannot be affected by other clients, even if they generate AUTO_INCREMENT values of their own. This behavior ensures that each client can retrieve its own ID without concern for the activity of other clients, and without the need for locks or transactions.

精简版:使用安全。

关于php - mysql_insert_id 使用安全吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31042509/

25 4 0
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com