I'm just wondering how much [un]lucky we would be to generate two identical numbers with simultaneous calls to:
uniqid( "", rand() );
The first part of uniqid seems to be based on time. This alone makes it pretty hard to generate twice the same number with sequential calls on a single computer.
The lcg value seems to make it near impossible to generate twice the same value with simultaneous calls on the same computer. You'd have to have calls happen exactly at the same microsecond and generate the same lcg value on top of that. You need a really bad random number generator and lots of simultaneous calls to run the chance to have collisions.
Of course I'm going to put a unique index on the column in which I'll put uniqid values. I'm still wondering how much likely it is to encounter a collision.
I may use mt_rand also to make the lcg better.
What are your thoughts on this subject? What is your experience with uniqid()? Is my reasoning too optimistic?
Thanks for your valuable input!