Ask a Question related to PHP Development, Design and Development.
-
Jan #1
unique id
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);
thanks
Jan
Jan Guest
-
Unique Form inserting into many tables using unique id
I have a Registration Form that have 3 steps. The data could be inserted into many (4) tables. Some data corresponding to a one table (the main or... -
Unique id on form
Hi, Our site is joining an affiliate program and we have a form where the user goes in and fill out. I need to gather that an email address the... -
Unique yet Eerie
I'm have a strange problem. I've encoutered a few before, but nothing like this: New machine with php4.2.2 on RedHat with Apache2.0 All my... -
Which Unique Sort From FAQ Is Better?
Also sprach Chinadian: Those two don't do the same thing. Both will uniquify the list, but only b) will sort them. The result of these two will... -
Unique Records in asp
Hi, How can I count only unique records in a recordset? (sql server 7.0). When I do a select query for an asp page, I may have more than 1... -
Tom Rogers #2
Re: [PHP] unique id
Hi,
Saturday, July 26, 2003, 5:58:41 PM, you wrote:
j> Hi there!
j> What's the best way to create uids (unique ids) even when runnig at
j> exactly same time (microseconds)?
j> is this enough ???
j> $r = mt_rand();
j> $uid = uniqid(getmypid() . $r);
j> thanks
j> Jan
I use:
$id = md5(uniqid(rand(),1));
--
regards,
Tom
Tom Rogers Guest
-
Curt Zirzow #3
Re: [PHP] unique id
* Thus wrote jan (jan@plazma.sk):
If you're running a cluster of machines I would include information> 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);
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."
Curt Zirzow Guest
-
Curt Zirzow #4
Re: [PHP] unique id
* Thus wrote Gabriel Guzman (gabe@careercast.com):
The only other way I have done it was to make a central database> On Sat, 2003-07-26 at 07:11, Curt Zirzow wrote:>> > * 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
> this is similar to what we do as well:
>
> hexadecimal timestamp + hexadecimal pid + hexadecimal randomvalue + hex
> ip address of server (only used if using multiple machines, otherwise
> this part is left off).
>
> I've also considered using semaphores in my id generation function to
> insure only one counter can be created at a time, but am worried that
> this might cause a bit of a performance hit. Anyone tried this?
with a table containing a auto incremented id. All scripts
would add a record and get back the auto incremented id number.
Since db inserts are atomic, it is guaranteed to be unique.
I think the biggest weak point in this approach is if the
connection goes down between the web server and db server, the
script is left clueless as what to do.
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
Curt Zirzow Guest



Reply With Quote

