I had enough trouble getting people I worked with a while back to use
functions, never mind CFCs!! That was my compromise :O)
The reason I first started wrapping queries in functions was to remove the
scope from the cfquery/cfstoreproc call
We would include query files but other developers would scope vars like:
<cfquery>
...
...
WHERE SomeID = #FORM.id#
</cfquery>
I didn't like the idea that you had to then make sure id existed in FORM
before you included the query file. So I started wrapping the query files in
functions and then the scope remains in the calling page.
<cffunction name="getAQuery" returntype="query">
<cfarguments name="id" required="yes" type="numeric">
<cfset var q = "">
<cfquery name="q" ...>
...
...
WHERE SomeID = #ARGUMENTS.id#
</cfquery>
<cfreturn q>
</cffunction>
And then
<cfinclude template="theQueryFile.cfm">
<cfset myQuery = getAQuery(FORM.id)>
or
<cfset myQuery = getAQuery(FORM.id)>
or
<cfset myQuery = getAQuery(URL.id)>
or
<cfset myQuery = getAQuery(SOMEOTHERSCOPE.id)>
or
<cfset myQuery =
getAQuery(FORM.someOtherVariableNameBecauseIDontLikeUsingID)>
But alas there was resistance to that too, extra typing don't you know! :OP
Ade
-----Original Message-----
From: Barney Boisvert [mailto:[EMAIL PROTECTED]
Sent: 23 February 2005 22:56
To: CF-Talk
Subject: Re: Reason to *not* store lots of data in Application scope?
Yes, that's exactly how you should go about doing caching. However,
rather than using a UDF and an application variable, use a CFC method
and then stash that CFC in the application scope. Much more flexible
and better encapsulated.
<cfcomponent>
<cffunction name="getQuery">
<cfset var q = "" />
<cfif NOT structKeyExists(variables, "myQuery")>
<cfquery name="q" ...>
</cfquery>
<cfset variables.myQuery = q />
</cfif>
<cfreturn variables.myQuery />
</cffunction>
<cffunction name="flushQuery">
<cfset structDelete(variables, "myQuery", false) />
</cffunction>
</cfcomponent>
cheers,
barneyb
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 22/02/2005
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:196244
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