A safe, transaction safe sequence emulation for MySQL. The docs explain some reasons you might want to allocate the object ID first, rather than afterwards.
Extracted out of a commercial app I wrote once.
I really need to write the equivalent for some other non-sequence-friendly database one of these days.