You are here: Re: unique id « All PHP « IT news, forums, messages
Re: unique id

Posted by roger on 05/10/05 09:27

ok thanks
"John Sjouken" <sjouken@iae.nl> wrote in message
news:427faa1d$1@nnrp1.psineteurope.com...
> The only things you can do is ask them if they are willing to make the row
> "UIQUE".
> An other thing is using a multification with timestamp and one of the
inputs
> which will change the mast, use MD5-hash with it multiply it and use it as
> an unique field.
> The only way to update this field is using the same time-stamp AND the
same
> input
> --
> John, PE1DSR
>
> http://ham.jen-gen.com
> "roger" <pageme@ntlworld.com> wrote in message
> news:T_vfe.26191$5A3.24594@newsfe4-win.ntli.net...
> > Its just the way the site is designed, i dont have any say on it. I just
> > have to write an app to work with the existing site..
> >
> > "Oli Filth" <catch@olifilth.co.uk> wrote in message
> > news:Ewsfe.22261$YF5.12348@newsfe5-win.ntli.net...
> > > roger wrote:
> > > > It cant be set to AutoIncement as it corresponds to the time the
> product
> > was
> > > > updated..
> > > > i have managed to do it using:
> > > >
> > > > $testid='1115571604';
> > > > $unique_result='1';
> > > > while($unique_result)
> > > > {
> > > > $rs= mysql_query("Select ID from Items where ID =
> > > > '$testid'");
> > > > if (mysql_fetch_array($rs))
> > > > {
> > > > $testid++;
> > > > }
> > > > else $unique_result = '0';
> > > > }
> > > > echo "$testid";
> > > >
> > > > but how can i lock it so no one straight after can grab the same
value
> > > > during the time it takes to execute the rest of the code following
> this.
> > >
> > > Why do you need it to correspond *uniquely* to the creation time? Like
I
> > > said previously, if you need a unique ID, then use the autoincrement
> > > feature. If you need a timestamp, then store the timestamp as well.
It's
> > > considered bad design practice to have one database field serving two
> > > purposes, not least because it involves kludges like this.
> > >
> > > What's more, by changing the ID field of records on UPDATEs, you're
> > > destroying the relational aspect of the database, because you can't
use
> > > this ID value as a foreign key in other tables (i.e. you can't
identify
> > > this row from other tables).
> > >
> > > But if you still want to do this, then use a table lock, i.e.
> > >
> > > LOCK TABLE table_name WRITE;
> > >
> > > ...
> > >
> > > UNLOCK TABLES;
> > >
> > >
> > > P.S. It would be much more efficient if you treat the ID value in your
> > > example above as an integer rather than a string.
> > >
> > > --
> > > Oli
> >
> >
>
>

 

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

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