> > You should always var your query name and use a query name 
> > to make it a local variable and avoid race conditions.
> 
> What for? All variable names are local by default anyway.

I think that the original statement referred to the use of queries (or other
variables) within a function/CFC method. In that case, if you create a
variable, you should make that variable local to the function/method if it's
only going to be used within that function. Otherwise, there's a minor risk
that you may clobber a variable in the program that calls the function.

> Furthermore, giving a name to a query will force CF to keep 
> the connection alive during the whole HTTP request, and use memory.
> Although I cannot be sure, logically, an unnamed query should 
> be garbaged as soon it is processed.

Garbage collection doesn't happen immediately when there are no longer
references to an object in Java, so I seriously doubt that it'll make any
difference whether you give your query a name or not. In addition, the
memory usage will be the same as well, since variable names are just
references to objects on the heap, which will exist whether they have
references or not until garbage collection occurs. Finally, I'm pretty
confident that even if garbage collection occurred, the unnamed query object
would exist until the CF page in question has completed execution -
otherwise, you wouldn't be able to reference CFQUERY.ExecutionTime at the
bottom of your page.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Check out the new features and enhancements in the
latest product release - download the "What's New PDF" now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

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

Reply via email to