RE: [PHP] How do you guys do this?
| From: | Michal Migurski | Date: | Sat, 31 Jan 2004 23:15:25 +0000 |
| Subject: | RE: [PHP] How do you guys do this? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176477@lists.php.net to get a copy of this message | ||
>> I used microtime() to differentiate them, but in retrospect it should
>> have been a no-brainer to use the database primary id to help
>> differentiate these, since the DB already did all the heavy lifting
>> involved in ensuring uniqueness.
>
>Even though it seems incredibly unlikely, isn't is safer to just not
>worry about it and use unique ids instead? Why take the risk when you
>can use an autonumber from a database or md5(uniqid(rand(), true)), or
>even: time() . md5(uniqid(rand(), true)) if you want to be really
>paranoid?
According to the docs, uniqid() relies on microtime() anyway, so it works
out to almost the same thing. You could just as well make a call to the
return value of the mktemp program, as well. Regardless, the important
thing is that you generate uniqueness /somewhere/ - if you're using a DB,
you get uniqueness for free! :)
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html