The problem with cfquery.executiontime is that it is a special
case/exception to the way ColdFusion treats variables.
cfquery is not a structure.
cfquery.executiontime is a variable with a . in the variable name.
In prior versions of ColdFusion this was fine, but CFMX automatically turns
variable declarations with a . in the name into a structure.
In order to turn cfquery.executiontime into a local function scoped variable
you would have to be able to do this:
<cffunction name="foo">
<cfset var cfquery.executiontime = "">
<cfset var myquery = "">
<cfquery datasource="somedsn" name="myquery">
SELECT 'blah'
</cfquery>
</cffunction>
The problem is that CFMX doesn't allow you to var scope a variable with a .
in the name.
If you try running the code above it will barf with an error saying:
'You cannot use a variable reference with "." operators in this context.'
I'm not 100% sure about all the tag scopes, but cfhttp, cffile, cfcatch and
cferror are all structures, so you can use the var keyword to locally scope
them in a function.
Personally I think that it's a bug that cfquery.executiontime is a named
variable rather than a structure with a key called executiontime. I have
filed
Spike
>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED] On Behalf Of Sean A Corfield
>Sent: Friday, February 13, 2004 8:55 AM
>To: [EMAIL PROTECTED]
>Subject: Re: [CFCDev] How should I define variable in a CFC?
>
>On Feb 13, 2004, at 6:53 AM, Christian Cantrell wrote:
>> ... and the "cfquery" struct is stored in the variables scope, which
>> is why this works:
>>
>> <cffunction name="myFunction"...>
>> ����� <cfset var q = ""/>
>> ����� <cfquery name="q">
>> ����������� SELECT * FROM Users
>> ����� </cfquery>
>> ����� <cfset reportExecutionTime()/>
>> ����� <cfreturn q/>
>> </cffunction>
>>
>> <cffunction name="reportExecutionTime">
>> ����� <cflog text="#cfquery.executionTime#"/> </cffunction>
>
>Which means that using "cfquery.*" is not thread safe if your
>CFC instance is in a shared scope. That's not good.
>
>What about other 'tag scope' variables like "cfhttp.*" and "cffile.*"?
>It sounds like we can't write a CFC to handle file upload and
>store it in application scope, for instance, since multiple
>simultaneous requests to upload files would trample on each other's
>(variables.)cffile.* information?
>
>> There does not appear to be a way to scope the "cfquery" struct just
>> to the myFunction function. Is this something people feel they need?
>> I personally have never had an issue with behavior, but if others
>> have, we can see about getting it changed.
>
>I think that every tag that creates its own 'scope' like this
>ought to do so as if it were declared with 'var' so that the
>tags are thread safe...
>
>Sean A Corfield -- http://www.corfield.org/blog/
>
>Got Mach II? -- http://www.mach-ii.com/
>
>----------------------------------------------------------
>You are subscribed to cfcdev. To unsubscribe, send an email to
>[EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
>in the message of the email.
>
>CFCDev is run by CFCZone (www.cfczone.org) and supported by
>Mindtool, Corporation (www.mindtool.com).
>
>An archive of the CFCDev list is available at
>www.mail-archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]