Re: Random Unique ID

From: Date: Wed, 21 Mar 2007 20:46:56 +0000
Subject: Re: Random Unique ID
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-251045@lists.php.net to get a copy of this message
Rabih Tayyem writes:
PS: I don't take credit for the code as it is a modified version of a code I found long time back (this same code is running on one of my applications for months without any problem)..
Thanks. I'll find use for that! However, altho I know that by making the random number big enough the likelyhood of collisions can be made vanishingly small, I was actually concerned with eliminating the possibility of collisions altogether by checking to see if the number had been used before. I just don't know how to do that properly with Mysql. Perhaps it is necessary to lock to table, check, make the insert and then unlock it. But I was hoping that there would be a simpler way. Best, Craig
On 3/21/07, ccspencer@softhome.net <ccspencer@softhome.net> 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@SoftHome.net        *
*                                    *
************************************** 
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
------------------------------------------------------
-     Virtual Phonecards - Instant Pin by Email      -
-           Large Selection - Great Rates            -
-     http://speedypin.com/?aff=743&co_branded=1     -
------------------------------------------------------ 
**************************************
*                                    *
*          Craig Spencer             *
*      ccspencer@SoftHome.net        *
*                                    *
************************************** 


« previous php.general (#251045) next »