|
Posted by "Richard Lynch" on 10/25/05 20:53
On Tue, October 25, 2005 4:01 am, Denis Gerasimov wrote:
> I am in a need of GUID generator but it seems that PHP doesn't have
> this as
> a built-in feature.
There is some discussion here you may find useful:
http://www.php.net/uniqid
> I really need "true" unique identifiers - md5() hash is not OK because
> of
> the "birthday paradox".
If you already have a database connection you can simply use a
sequence (or auto_increment in MySQL)
But that assumes you are willing to have predictable IDs, which you
might not.
> Can anyone recommend a way for solving this trouble?
You could use md5() and track every ID you hand out in a UNIQUE column
in a db, and simply generate another random md5() if you happen to run
into a duplicate.
The probability that you'd generate too many duplicate random md5()s
in a row for performance to be an issue is pretty small, if you
already have database activity going on.
--
Like Music?
http://l-i-e.com/artists.htm
[Back to original message]
|