Re: Re: Create unique non-autoincrement key for700,000records?

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

 



On Tue, 2008-12-16 at 09:56 +0100, Ondrej Kulaty wrote:
> Sorry you are right. He said he wants each row to have an unique ID so 
> AutoIncId+timestamp will satisfy it, But still i think that adding 
> microseconds timestamp is better because it will be harder for potential 
> hacker to guess.

I agree, but then each entry would need ot be updated individually.
Unfortunately MySQL doesn't appear to offer a time function to obtain
microseconds. However, using the same argument for non collision and
knowing that auto increment ID + unix_timestamp() must result in an
integer, one could use the following to produce a less guessable
outcome:

    update
        mytable
    set
        hash_field = md5( concat( AutoIdField + unix_timestamp(),
rand() ) )

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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