
Query Caching
If you do not have a version of Cold Fusion that supports query caching, you can use an application variable for the query name and the query will always be available in memory. I have an example in the accompanied HTML/CFML code block below that you can use to model your query after. Put this in your application.cfm so that the query will always be available to any programs that need it. To reference the application query, simply use the application variable name. Just remember, queries such as these should be relativly small as they will be consuming system resources.
Example HTML/CFML code:
<CFIF IsDefiend("application.MyQuery") EQUAL "No">
<CFQUERY name="application.MyQuery" .....>
SELECT *
FROM MyTable
</CFQUERY>
</CFIF>
....
<CFLOOP query="application.MyQuery")>
...
</CFLOOP>
Return to the Cold Fusion Tips-N-Tricks topic list