On Sat, 2007-03-24 at 08:24 -0400, Jim McIntyre wrote:
> IIRC, the OP wanted to generate a unique key precisely to keep from
> revealing the record ID to the end user... what about taking the
> auto_increment value (easy to generate, assured to be unique) adding its
> MD5 hash to another column in
IIRC, the OP wanted to generate a unique key precisely to keep from
revealing the record ID to the end user... what about taking the
auto_increment value (easy to generate, assured to be unique) adding its
MD5 hash to another column in the table, then using that as the
"published" ID?
The only dis
Use auto_increment.
It's not random, but you should never show it to the end user anyway,
so who cares?
Another option is to use http://php.net/uniqid and you can create a
UNIQUE INDEX on the column and simply check mysql_errno() to see if
it's 1023 (or is it 2023?) when you insert to see if you
2007. 03. 23, péntek keltezéssel 15.13-kor tedd ezt írta:
> At 9:15 AM +0100 3/23/07, Németh Zoltán wrote:
> >2007. 03. 22, csütörtök keltezéssel 12.58-kor tedd ezt írta:
> >> At 4:53 PM +0100 3/22/07, Németh Zoltán wrote:
> >> >2007. 03. 22, csütörtök keltezéssel 11.42-kor tedd ezt írta:
> >> >
At 9:15 AM +0100 3/23/07, Németh Zoltán wrote:
2007. 03. 22, csütörtök keltezéssel 12.58-kor tedd ezt írta:
At 4:53 PM +0100 3/22/07, Németh Zoltán wrote:
>2007. 03. 22, csütörtök keltezéssel 11.42-kor tedd ezt írta:
>
> > As for efficiency, that's probably not
even worth mentioning in thi
2007. 03. 23, péntek keltezéssel 08.13-kor Robert Cummings ezt írta:
> On Fri, 2007-03-23 at 09:15 +0100, Németh Zoltán wrote:
>
> > // method 2
> > $time = microtime(TRUE);
> > for ($i = 1; $i <= 5000; $i++) {
> > $done = FALSE;
> > while (!$done) {
> > $id = md5((microtime(TR
On Fri, 2007-03-23 at 09:15 +0100, Németh Zoltán wrote:
> // method 2
> $time = microtime(TRUE);
> for ($i = 1; $i <= 5000; $i++) {
> $done = FALSE;
> while (!$done) {
> $id = md5((microtime(TRUE) * (rand(1,1000) / 100)));
> $sql = "INSERT INTO idtest (id,cn
2007. 03. 22, csütörtök keltezéssel 12.58-kor tedd ezt írta:
> At 4:53 PM +0100 3/22/07, Németh Zoltán wrote:
> >2007. 03. 22, csütörtök keltezéssel 11.42-kor tedd ezt írta:
> >
> > > As for efficiency, that's probably not even worth mentioning in this
> > case.
> >
> >why not? you would use 2 sq
2007. 03. 22, csütörtök keltezéssel 12.58-kor tedd ezt írta:
> At 4:53 PM +0100 3/22/07, Németh Zoltán wrote:
> >2007. 03. 22, csütörtök keltezéssel 11.42-kor tedd ezt írta:
> >
> > > As for efficiency, that's probably not even worth mentioning in this
> > case.
> >
> >why not? you would use 2 sq
At 4:53 PM +0100 3/22/07, Németh Zoltán wrote:
2007. 03. 22, csütörtök keltezéssel 11.42-kor tedd ezt írta:
> As for efficiency, that's probably not even worth mentioning in this case.
why not? you would use 2 sql queries while I would use one most of the
time and 2 in case of already reserved
2007. 03. 22, csütörtök keltezéssel 11.42-kor tedd ezt írta:
> At 4:28 PM +0100 3/22/07, Németh Zoltán wrote:
> >2007. 03. 22, csütörtök keltezéssel 11.24-kor tedd ezt írta:
> >> At 11:18 AM -0600 3/21/07, [EMAIL PROTECTED] wrote:
> >> >Hello,
> >> >I want to add a random unique ID to a Mysql ta
At 4:28 PM +0100 3/22/07, Németh Zoltán wrote:
2007. 03. 22, csütörtök keltezéssel 11.24-kor tedd ezt írta:
At 11:18 AM -0600 3/21/07, [EMAIL PROTECTED] 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
2007. 03. 22, csütörtök keltezéssel 11.24-kor tedd ezt írta:
> At 11:18 AM -0600 3/21/07, [EMAIL PROTECTED] 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
At 11:18 AM -0600 3/21/07, [EMAIL PROTECTED] 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
function GenerateID ()
{
$len = 3;
$base='ABCDEFGHKLMNOPQRSTWXYZ';
$max=strlen($base)-1;
$activatecode='';
mt_srand((double)microtime()*100);
while (strlen($activatecode)<$len+1)$activatecode.=$base{mt_rand(0,$max)};
$len = 7;
$base='1234567890';
$max=strlen($base)-1;
mt_srand((double)microti
[EMAIL PROTECTED] wrote:
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
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,
17 matches
Mail list logo