You are here: is this okay? « PHP Programming Language « IT news, forums, messages
is this okay?

Posted by siliconmike on 10/22/05 03:58

pseudocode:

function generate_unique_id()
{
mkdir("lock");

if successful
{
$id = 10 digit random number;
make sure that $id does not exist in our table
if it does, generate a new one

insert $id into our table;

rmdir("lock");
}
else try mkdir again
}

do you see any race conditions?

this idea could be dangerous if the script died before rmdir("lock")..
any solution?

[I can't use auto-increment .. long story]

Mike

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация