Re: Random Unique ID

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

 



Use auto_increment.

It's not random, but you should never show it to the end user anyway,
so who cares?

Another option is to use http://php.net/uniqid and you can create a
UNIQUE INDEX on the column and simply check mysql_errno() to see if
it's 1023 (or is it 2023?) when you insert to see if you had a
collision.

On Wed, March 21, 2007 12:18 pm, ccspencer@xxxxxxxxxxxx wrote:
> Hello,
>
> I want to add a random unique ID to a Mysql table.  Collisions
> are unlikely but possible so to handle those cases I'd like to
> regenerate the random ID until there is no collision and only
> then add my row.  Any suggestions for a newbie as to the right
> way to go about doing this?
>
> Best,
>
> Craig
>
>  ------------------------------------------------------
>  -     Virtual Phonecards - Instant Pin by Email      -
>  -           Large Selection - Great Rates            -
>  -     http://speedypin.com/?aff=743&co_branded=1     -
>  ------------------------------------------------------
>
>
> **************************************
> *                                    *
> *          Craig Spencer             *
> *      ccspencer@xxxxxxxxxxxx        *
> *                                    *
> **************************************
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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