|
|
 |
Re: FN-FORUM: What's the best development platform for creating Web 2.0 business applications?
date posted 21st November 2007 14:41
Hello Alex,
On 21 Nov 2007 15:15:24 -0000, Alex Townsend wrote
> Quoting Dom Latter [EMAIL REMOVED]
> > Why on earth not?
> >
> > I tend to stick an auto-increment ID and a timestamp on *everything* -
useful
> > for debugging.
>
> I agree - well, I always use an auto_increment ID column. I tend
> not to use auto-timestamps, because I found I had a lot of issues
> with them auto-updating every time something was done to that row
That is exactly what the timestamp field is supposed to do. I know its a
misnomer, but it doesn't really have anything to do with the time. Its a
field which changes (in a unique way) every time something happens to that
row (create, read or update). It is used for optimistic locking on multi-
user systems, like so....
update Customer
set
Name = @Name,
Address = @address
Where
Id = @Id and
OptimisticLockingToken = @UserOLToken
That way if you read a record and I read a record and you update a field and
write it back, the timestamp changes; when I go to write my record back the
timestamps don't match (as per the sql above) and I get an error, thus
preventing my changes from over-writing yours. Cool eh? :-)
--
Gary Short
http://www.garyshort.org
|
 |
|