Yes! you could be right... it depens of course if you have instantiated the CFC into a Shared Scope.... If you have not done this.... meanings that you instantiate the CFC each time... you won't have any problem calling fList2()... but if you have instantiated the CFC into a Shared Scope... Yes you could have the problem that you describe... you might get the list of the users... or the other one... if you are calling both function fList1 and fList2 many many times... because the query variable "qList" is global... So! it all depend of the times...  
 
To correct this situation, you will need to add this line at the beginning of your functions...
 
<cfset var qList = ''>
 
And you will be sure, that it will return the right thing...
 
Stephane
----- Original Message -----
From: Joel Nath
To: CFC_Dev
Sent: Sunday, August 24, 2003 11:00 PM
Subject: [CFCDev] Queries in CFC's

hi,
 
i was wondering  if i have the following CFC
 
<cfcomponent>
 
<cffunction name="fList1">
 
    <cfquery name="qList">
        select * from users
    </cfquery>
 
    <cfreturn qList.Recorccount>
</cffunction>
 
 
<cffunction name="fList2">
 
    <cfset var tempCount = 0>
 
    <cfquery name="qList">
        select * from customers
    </cfquery>
 
    <cfscript>
        tempCount = fList1();
    </cfscript>
 
    <cfreturn qList>
</cffunction>
 
</cfcomponent>
 
 
the two queries qList in Function fList1 and fList2 are GLOBAL Private variables queries, hence its in the un-names scope
 
hence if i call fList2() it will return the Users Query Object
 
so they is a chance of qList returning the wrong data
 
 
is this example correct.. and does it make sence...:)
 
 
 
cheers
joel

Joel Nath
Senior Developer
Redsquare
[EMAIL PROTECTED]
Work: +61 2 8596 4067

Mobile: 0414 303965
49 Greek Street
Glebe, 2037
NSW, Australia
Visit us at www.redsquare.com.au for more information.
 

Reply via email to