Re: Re: Unique Object Instance ID..?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2009-01-11 at 00:07 +0000, Nathan Rixham wrote:
> Colin Guthrie wrote:
> > 'Twas brillig, and Nathan Rixham at 10/01/09 23:31 did gyre and gimble:
> >> all I need is a completely unique id for each object instance that can 
> >> never be repeated at any time, even in a multiserver environment (and 
> >> without using any kind of incremented value from a db table or third 
> >> party app)
> >>
> >> thoughts, ideas, recommendations?
> > 
> > While it's not guaranteed to be unique the general technique used in 
> > these situations is to use a UUID. The chances of a clash are slim 
> > (2x10^38 ish combinations).
> > 
> > You can generate a uuid via mysql "SELECT UUID()" or via the PHP Pecl 
> > extension php-uuid.
> > 
> > The other way of doing it would be to insert a row into a database row 
> > with an auto-increment field and use the value of that auto-incrment 
> > field as your identifier (SELECT LAST_INSERT_ID() in mysql or via the db 
> > layers API).
> > 
> > HTHs
> > 
> > Col
> > 
> > 
> 
> cheers for the input; uuid it has to be I guess; don't want it reliant 
> on any third party software or db so pecl is out, as is mysql - looks 
> like I'm going to have to (and probably enjoy) making a uuid function to 
> generate type 4 random uuids.
> 
> only other thought is to combine all the instance variables, hash the 
> combination of them and save that together with a timestamp..

Use microtime for your timestamp... much less likely to have a collision
than using seconds.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux