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 Link to comment https://forums.phpfreaks.com/topic/23906-mysql_insert_id-or-last_insert_id/ 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. Link to comment https://forums.phpfreaks.com/topic/23906-mysql_insert_id-or-last_insert_id/#findComment-108653 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. Link to comment https://forums.phpfreaks.com/topic/23906-mysql_insert_id-or-last_insert_id/#findComment-108654 Share on other sites More sharing options...
digitalgod Posted October 13, 2006 Author Share Posted October 13, 2006 alright thanks guys Link to comment https://forums.phpfreaks.com/topic/23906-mysql_insert_id-or-last_insert_id/#findComment-108664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.