digitalgod Posted October 13, 2006 Share Posted October 13, 2006 Which one should I use?I have a query that inserts some info into a table named nights, when that query is done I have another one that inserts info into a table named rTables, in rTables I also have to insert the id of the last inserted row. If i I use mysql_insert_id() it might give me the id of another table if someone else is doing something on the site.I was wondering if LAST_INSERT_ID() does the same thing.. and what would be the best way of getting the id of the last row added in a table Quote Link to comment Share on other sites More sharing options...
Barand Posted October 13, 2006 Share Posted October 13, 2006 mysql_insert_id() returns the last value for the current db connection so is unaffected by anyone else. Quote Link to comment Share on other sites More sharing options...
trq Posted October 13, 2006 Share Posted October 13, 2006 mysql_insert_id() is the one you want. It will only retrieve the last id generated for the corrent connection. LAST_INSERT_ID will retrieve the last (global) insert id. Quote Link to comment Share on other sites More sharing options...
digitalgod Posted October 13, 2006 Author Share Posted October 13, 2006 alright thanks guys Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.