Make a persisted CFC and put the query in it at a variables scope variable. 
As long as the CFC is persisted, the query is persisted. MUCH cleaner than 
cachedwithin/cachedafter. I have an article on it waiting to go which I can 
send you off list (it's pre-edit)


> I've got a simple query that will grab all my navigational menu items.
> pretty simple.  Now, I've added Mike D's cf_maketree script to modify
> the query by adding another field, called maketreesortlevel, that stores
> the tree level so that I can output the menu items in the correct order
> and depth.  this query gets rather big, since I've got over 1300
> categories and subcategories, so I'd like to be able to cache it.  i
> know how to use cachedwithin as a cfquery attribute, but this won't work
> here, since I am modifying that query.  is there another way to cache a
> query?  here's the code, if it helps:
>
> <cfif NOT isdefined("qry_get_topcats") or isdefined("attributes.refresh")>
>
> <cfquery name="qry_get_topcats" datasource="#Request.DS#"
> username="#Request.user#" password="#Request.pass#"
> cachedwithin="#Request.Cache#">
> SELECT Category_ID, Name, Parent_ID, ParentIDs
> FROM Categories
> WHERE Categories.Display = 1
> ORDER BY Priority, Name
> </cfquery>
>
> <!--- this script modifies the query to add 'maketreesortlevel' --->
> <cfmodule
> template="make_tree.cfm"
> Query="#qry_get_topcats#"
> Result="qry_get_topcats"
> Unique="category_ID"
> Parent="Parent_ID">
> </cfif>
>
> TY
>
> Ray
>
> -- 
> =================================================================
> Ray Champagne - Senior Application Developer
> CrystalVision Web Site Design and Internet Services
> 603.433.9559
> www.crystalvision.org
> =================================================================
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:219630
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to