Looks like I found a bug in coldfusion in regards to varing variables in a
cfc.  Here is the example code to reproduce. 

 

            <cffunction name="method1">

                  <cfset var myQryTest="">

 

                  <cfquery name="myQryTest"
datasource="#application.mydsn#">

                        DELETE FROM  table 

                        WHERE tableid=-1

                  </cfquery>  

                  

                  <cfquery name="myQryTest"
datasource="#application.mydsn#">

                        select tableid from users where tableid=1

                  </cfquery>  

            </cffunction>     

            <cffunction name="method2">

                  <cfdump var="#myQryTest#">

            </cffunction>     

 

 

Then run this on a test page.  

<cfobject name="application.mycomponent" component="mycomponent">

<cfinvoke component="#application.mycomponent #" method="method1">

<cfinvoke component="#application mycomponent #" method="method2">

 

If you've set everything up right, you'll see a dump of a query.  In reality
you should be getting an exception.  

 

 

I think what happens is when the first query runs, it deletes the variable,
since it doesn't return anything.  When the second select query runs, it
recreates the variable as a regular variable which is local to the cfc, not
the function.  

 

Is this a CF bug?  I got around it by creating a local struct and then
putting those variables into that struct, but in general, this is not
intended behaviour, correct?  

 

 

 

Russ



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250061
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to