
19 Jan
2011
19 Jan
'11
3:22 p.m.
On Wed, Jan 19, 2011 at 3:19 PM, Chris Mwirigi <mwirigic@gmail.com> wrote:
you get the last insert id based on your connection, and concurrent operations will have different connections, so the case of mixed up keys wont happen. A more real concern though would be if your insert fails, this would mean that getting the last id would fetch the last successful insert on that connection and use it
The behaviour of last_insert_id() changes based on the version of MySQL you are using, especially if the most recent INSERT or UPDATE failed. The page below explains the differences: http://dev.mysql.com/doc/refman/5.1/en/mysql-insert-id.html