But if the query relies on data from the browser then using a persistent scope will be a bit of a drag since you'd have to provide some way to identify the correct recordset depending on the values of the parameters passed - presumably by dynamically naming the query depending on the parameters being passed, and then copying/pointing that to a common name, or am I missing something?

An alternative is to cache a query of query:

<cfparam name="url.id" default="1">
<cfset somethingunique = 'the ID is #url.id#'>
<cftry>
<cfquery name="cachedQuery" dbtype="query" cachedwithin="#CreateTimeSpan(0,0,0,10)#">
SELECT *
FROM realquery
WHERE '#somethingunique#' = '#somethingunique#'
</cfquery>
<cfcatch>
<cfquery datasource="#request.dsn#" name="realquery">
SELECT <cfqueryparam value="#url.id#" cfsqltype="CF_SQL_INTEGER">
, #now()#
</cfquery>
<cfquery name="cachedQuery" dbtype="query" cachedwithin="#CreateTimeSpan(0,0,0,0)#">
SELECT *
FROM realquery
WHERE '#somethingunique#' = '#somethingunique#'
</cfquery>
</cfcatch>
</cftry>

<cfdump var="#cachedQuery#">

Cheers
Bert

> ________________________________
>
> From: Dave Watts [mailto:[EMAIL PROTECTED]
> Sent: 31 July 2004 19:26
> To: CF-Talk
> Subject: RE: cfqueryparam best practices
>
>
> > Caching queries will not work using cfqueryparam.
>
> No, but if your choice is to either cache a query or
> use CFQUERYPARAM, and
> that query accepts data directly from the browser
> (Form, URL, Cookie
> variables), I'd recommend you use CFQUERYPARAM. As
> others have pointed out,
> you can cache queries in the Application, Session and
> Server scopes.
>
> Dave Watts, CTO, Fig Leaf Software
> http://www.figleaf.com/
> phone: 202-797-5496
> fax: 202-797-5444
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to