Re: Re: Create unique non-autoincrement key for700,000records?
| From: | Robert Cummings | Date: | Tue, 16 Dec 2008 09:24:39 +0000 |
| Subject: | Re: Re: Create unique non-autoincrement key for700,000records? | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-284657@lists.php.net to get a copy of this message | ||
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