Re: Unique Object Instance ID..?

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

 



'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


--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


--
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