last record ID

I am inserting record then getting the id using mysql_insert_id() from an auto increment field.

Will it always pull up the last id, entered by that user, or if another user add something,  is there a risk it could pull up the id for their record?

LVL 1
debbieau1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cyberkiwiCommented:
It will always be for the user session, irrespective of what other users do.  It is stored specific to the user session, in other words.
0
cyberkiwiCommented:
MySQL reference - http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html

For LAST_INSERT_ID(), the most recently generated ID is maintained in the server on a per-connection basis. It is not changed by another client. It is not even changed if you update another AUTO_INCREMENT column with a nonmagic value (that is, a value that is not NULL and not 0). Using LAST_INSERT_ID() and AUTO_INCREMENT columns simultaneously from multiple clients is perfectly valid. Each client will receive the last inserted ID for the last statement that client executed.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
debbieau1Author Commented:
Thanks, that's a great help

Can I confirm that in my case last_insert_id() would be better to use.  I am not clear on the difference.

Also I did read somewhere that using mysql_insert_id() is a time bomb for very large tables.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.