Hi,
 
the dev team  always instantiates the CFC into a shared scope.. hence we are in the middle of making some standards for cfc's to be used by our dev team...
 
what we were thinking of was to create a struct within each CFFunctions and any local vars that need to be created within the function are part of the struct.
 
can anyone see anything wrong with this idea..?
 
 
i wished they had made a prefix for the un-named scope (Global Private Vars).. would have made things abit simpler
 
.eg
 
<cfcomponent>
 
<cffunction name="fList1">
   
    <cfset var stLocal = StructNew()>
 
    <cfquery name="stLocal.qList">
        select * from users
    </cfquery>
 
    <cfreturn stLocal.qList.Recorccount>
</cffunction>
 
 
<cffunction name="fList2">
 
    <cfset var stLocal = StructNew()>
 
    <cfquery name="stLocal.qList">
        select * from customers
    </cfquery>
 
    <cfscript>
        stLocal.tempCount = fList1();
    </cfscript>
 
    <cfreturn stLocal.qList>
</cffunction>
 
</cfcomponent>
 
 
cheers
joel
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of St�phane Bisson
Sent: Monday, 25 August 2003 1:20
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] Queries in CFC's

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