generating unique id's

From: Date: Wed, 28 Jun 2000 22:10:31 +0000
Subject: generating unique id's
Groups: php.db 
Request: Send a blank email to php-db+get-717@lists.php.net to get a copy of this message
Hello, I need to generate a unique id. The problem I am running into is this: I have a for loop that generates a bunch of id's using the time() function, the problem is that since the for loop only takes less than a microsecond, and the precision of the time() function is a microsecond, all the id's are the same. I looked into using uniqid(), which according to the PHP manual generates an INT. However, I tested it out, and in a microsecond it DOES generate a series of different, random STRINGS, mix of ints and characters, NOT an INT, which like I said is what the PHP manual uses. MySQL requires that the primary key be an INT, so I can use uniqid() function to generate this id, because its a string. What can I do? In summary, generate a whole list of unique INTEGER id's in under a microsecond... Thanks /Cody Caughlan

« previous php.db (#717) next »