Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfparam vs structkeyexists and isdefined

Status
Not open for further replies.

ice78991

Programmer
Nov 20, 2006
216
I have read that Coldfusion 8 is super fast at dealing with cfparam ( I think Ben Forta recorded it at 300 times faster than Coldfusion 7 )


In the light of this what is the best way to do data validation

At the moment I define each variable with a cfparam

<cfparam name="url.somevar" default="">

and then I check for its existence with


<cfif len(url.somevar) gt 0>
....validate
</cfif>

Is this a good approach or would it be better to use structKeyExists(..) as follows

<cfif structKeyExists(url,"somevar")>
..validate
</cfif>
 
Sorry, I mean cfparam about 30 times faster...
 
i really like the CFPARAM approach, because you can default it to some weird value and test for that

defaulting the URL variable to an empty string isn't very robust, because it's easy to submit the url with an empty string



r937.com | rudy.ca
 
So rather than defaulting to an empty string with cfparam is it better to use

<cfif structKeyExists(url,"somevar")>
..validate
</cfif>

Is there a performance penalty for using too many cfparams in a high load site even in Coldfusion 8 ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top