在mysql中替代mysql_insert_id? [英] Alternative for mysql_insert_id in mysql?

查看:81
本文介绍了在mysql中替代mysql_insert_id?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用google_mysql_insert_id来查询线程安全问题... ...我担心我只有一个MySQL用户来连接数据库,因此,我认为mysql_insert_id对于我的应用程序不是很安全.是否有任何安全"的方法可以从MySQL返回最后一个插入ID?谢谢.

I google the mysql_insert_id, about the thread safe concern... ...I am worrying about I only have a one MySQL user to connect DB, so, I think mysql_insert_id is not very safe for my application. Is there any "safer" method for returning last insert id from MySQL? thank you.

推荐答案

只要没有两个线程共享一个数据库连接,就不应获取任何错误的ID. mysql_insert_id是按连接而不是按用户存储的.

As long as no two threads share one database connection you should not get any wrong ids. mysql_insert_id is stored per connection, not per user.

这篇关于在mysql中替代mysql_insert_id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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