Hi. I'm changing from using auto-incrementing integers as the primary key for some of my tables to using a UUID for the primary key. I recognize that there will be a performance trade-off for this - but I am designing the system to support offline mobile clients who will periodically re-synchronize. For those tables that the off-line clients will be generating new records for, I have decided to take the hit and use a UUID as the primary key.
That said, I have code like the following:
$query=("INSERT INTO my_table VALUES(UUID(), 'foo', 'bar', 'baz');");
$result=mysql_query($query);
I had previously then called mysql_insert_id() to get the primary key of the last record that I had inserted. However, this doesn't work when I've changed the primary key to a varchar(36) instead of some auto-incrementing integer.
What is the best way to get the UUID for the last row I inserted?






Bookmarks