Jim Moseby writes:
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.

One way is to make your id field a unique key. MySQL will not let you insert a record with a duplicate unique key, and will issue an error. Your code should always check for errors on insert anyway, so if you get an error, generate a new key and try again.

Thanks.  Yes, I check for errors.  But there are other types of errors
so I'd need to verify that it is a duplicate key error and, in my
ignorance, I have not yet figured out how to do that programatically.
I worry about getting into an infinite loop. Best, Craig


------------------------------------------------------
-     Virtual Phonecards - Instant Pin by Email      -
-           Large Selection - Great Rates            -
-     http://speedypin.com/?aff=743&co_branded=1     -
------------------------------------------------------

**************************************
*                                    *
*          Craig Spencer             *
*      [EMAIL PROTECTED]        *
*                                    *
**************************************
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to