Re: unique id
| From: | Curt Zirzow | Date: | Sat, 26 Jul 2003 14:11:30 +0000 |
| Subject: | Re: unique id | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-156999@lists.php.net to get a copy of this message | ||
* Thus wrote jan (jan@plazma.sk):
> Hi there!
>
> What's the best way to create uids (unique ids) even when runnig at
> exactly same time (microseconds)?
>
> is this enough ???
>
> $r = mt_rand();
> $uid = uniqid(getmypid() . $r);
If you're running a cluster of machines I would include information
on the machine that is generating the uid.
$uid = uniqid(getmypid() . $r . '_MACHINE_NAME_');
Curt
--
"I used to think I was indecisive, but now I'm not so sure."