> 
> Two follow up questions.  You can't directly use the var key 
> word in the <cfquery> tag; <cfquery name="var joe"...>.  

Correct. You also can't do <cfset var ...> after any line of real code.
So, your first N lines of a method will be cfargument tags, then cfset
var tags, then 'real' code. 

So, that's why you saw me do:

<cfset var q = "">

<cfquery name="q" .....>


> Also, when exactly does this data get garbage collected?  

Um, I'm assuming when the method is done.

> Since it is in a method, does a query get created and 
> destroyed every time that method is used?  I does it persist 
> for the life of the entire component?
> 

The query does NOT persist because I used the var scope. However,
imagine a case where you query to get the states in the US. This will
not change anytime soon. Your code could look like so (pseudo-code):

(above, in the constructor area)
<cfset local = structNew()>

<cffunction name="getStates" ....>

        <cfset var q = "">

        <cfif not structKeyExists(local,"states")>
                run a query and get the states in query named q
                <cfset local.q = duplicate(q)>
        </cfif>

        <cfreturn local.q>

</cffunction>

In this example, the query persists as long as the CFC persists.

========================================================================
===
Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc
(www.mindseye.com)
Member of Team Macromedia (http://www.macromedia.com/go/teammacromedia)

Email    : [EMAIL PROTECTED]
Blog     : www.camdenfamily.com/morpheus/blog
Yahoo IM : morpheus

"My ally is the Force, and a powerful ally it is." - Yoda 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to