> > <cfquery name="GetCounter"...
> >     SELECT HitCount
> >     From...
> > </cfquery>
> > <cfset Counter = GetCounter.HitCount + 1>
> > <cfquery name="UpdateCounter"...
> >     UPDATE ...
> > </cfquery>
>
> You really need to make things like that a transaction 
(cftransaction).
> Think what happens if your current value was 2, and two ppl came at 
once,
> read 2 from the database, and both write 4 back... you've missed a 
hit.

Yeesh, why not just do it in one CFQuery

<cfquery datasource="myDSN">
        update myTable
        set HitCounter=HitCounter+1
        wehere myField=#myValue#
</cfquery>

SQL will do it a lot faster than 2 queries and a CFSet
Although, if it's NULL, you'll have to do something a little more 
special
(depending on the database engine)

Philip Arnold
Director
Certified ColdFusion Developer
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to