Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

LAST_INSERT_ID( )

Codes here !

Moderators: macek, egami, gesf

LAST_INSERT_ID( )

Postby ChrisSkidmore » Thu Feb 20, 2003 12:32 am

Hi,

My basic question is . "is LAST_INSERT_ID( ) a value returned everytime an insert query is run?"

Why?
Inserting into two tables: The second insert contains the auto_increment value from the first.

I have two users on line. User X clicks the button to send the form which is saved in the database.
Before the server has parsed the next line of code containing my 2nd insert query with LAST_INSERT_ID( ) user Y sends his form updating the auto_increment field.

I suspect I'm ok here and it would only return the last_user_id for a specific connection but I'd be grateful if you could confirm this so I can sleep easy tonight!!

Chris
ChrisSkidmore
New php-forum User
New php-forum User
 
Posts: 19
Joined: Sun Aug 18, 2002 4:02 am
Location: Germany

Postby pootergeist » Thu Feb 20, 2003 3:40 am

yup - you'd be fine.

the mysql_insert_id would only reference the auto_inc field of the record that was inserted for the script in question - it wouldn't even know about the second person doing the same.
pootergeist
New php-forum User
New php-forum User
 
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK

Postby ChrisSkidmore » Thu Feb 20, 2003 3:52 am

thank you!
ChrisSkidmore
New php-forum User
New php-forum User
 
Posts: 19
Joined: Sun Aug 18, 2002 4:02 am
Location: Germany


Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron