Why not simply store the query in the session scope? (This code assumes
MX and no need for locks.)

<cfif not isDefined("session.qGetSite")>
        <cfquery name="session.qGetsite" ....
        ...
        </cfquery>
</cfif>

Then you can simply...

<cfoutput query="session.qGetSite">
...
</cfoutput>

This also gives the added benefit of giving you a quick way to remove
the query:

<cfset structDelete(session,"qGetSite")>

Just remember that each session will have it's own query, so if your
site is _very_ busy and the query is big, your going to eat up a lot of
RAM.

=======================================================================
Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc

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

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

> -----Original Message-----
> From: Joshua Miller [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, January 16, 2003 12:25 PM
> To: CF-Talk
> Subject: Query Caching Question
> 
> 
> Ok, I've been reading up on query caching today and I think 
> I've run into something that may cause me problems unless 
> there is a way to dynamically name queries.
>  
> I have an application that houses data for multiple "sites" - 
> the data is referenced by a siteID that is set as a session variable.
>  
> So for example:
>  
> <cfquery datasource="#request.dsn#" name="qGetSite">
> SELECT sitename 
> FROM tblSites
> WHERE siteID=#session.siteID#
> </cfquery>
>  
> If I try to cache this query, then if someone logs in with a 
> siteID of 20 then they'll get their data, unless the query is 
> cached, then they'll get the data of whoever logged in the 
> last time - no matter what their siteID correct?
>  
> Is there a way to create a dynamic queryname?
>  
> I tried: <cfquery datasource="#request.dsn#" 
> name="qGetSite#session.siteID#"> and it worked to create the 
> query, but for subsequent references I'm getting errors like on:
>  
> This errors: <cfif qGetSite#session.siteID#.recordcount GT 0> 
> This errors: <cfset queryct="qGetSite#session.siteID#.recordcount">
>                  <cfif evaluate(queryct) GT 0> 
>  
> Is there a way I can dynamically name my query so that I can 
> use query caching without giving users the wrong data?
>  
> Can I turn off all query caching and then specify queries to 
> cache using the CACHEDWITHIN statement for queries that don't 
> rely upon the siteID?
>  
> Thanks,
>  
> Joshua Miller
> Head Programmer / IT Manager
> Garrison Enterprises Inc.
> www.garrisonenterprises.net <http://www.garrisonenterprises.net/> 
> [EMAIL PROTECTED]
> (704) 569-9044 ext. 254
>  
> **************************************************************
> **********
> *************
> Any views expressed in this message are those of the 
> individual sender, except where the sender states them to be 
> the views of 
> Garrison Enterprises Inc.
>  
> This e-mail is intended only for the individual or entity to 
> which it is addressed and contains information that is 
> private and confidential. If you are not the intended 
> recipient you are hereby notified that any dissemination, 
> distribution or copying is strictly prohibited. If you 
> have received this e-mail in error please delete it 
> immediately and advise us by return e-mail to 
<mailto:[EMAIL PROTECTED]>
[EMAIL PROTECTED]
************************************************************************
*************
 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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.

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

Reply via email to