Not to mention that 1 copy that is application wide, compared to a copy for
every request saves memory too.

Regards,
Andrew Scott

Quote of the Day:
Ed Okin:  Are we under arrest or what? FBI Agent:  I think you fall into the
'or what' category.


-----Original Message-----
From: Andy McShane [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 14 September 2005 7:13 PM
To: CF-Talk
Subject: RE: When to use Application var?

Personally, if your information is unlikely to change on any regular basis
then I would use the application scope. As for having too much in the
app.scope I suppose it really depends on the machine and how much memory you
have to play with. If what you have below is all that have in the app scope
then there should be no problem at all.

-----Original Message-----
From: Andy Jarrett [mailto:[EMAIL PROTECTED] 
Sent: 14 September 2005 10:08
To: CF-Talk
Subject: When to use Application var?

I have a bit of code on a smallish, low hit site


<cfset thisSiteName = ListGetAt(cgi.script_name, 1, "/")/>

<cfif NOT application.init OR structKeyExists(url, "reinit")>
        <cfquery datasource="#variables.dsn#" name="thisCompany">
                SELECT * 
                FROM companydetails c
                WHERE c.company_folder = '#thisSiteName#'
        </cfquery>
        <cfset application.companyName = thisCompany.company_name />
        <cfset application.companyWebsite = thisCompany.company_website />
        <cfset application.companyEmail = thisCompany.company_email />
        <cfset application.companyId = thisCompany.company_uid />
        <cfset application.companyfolder = thisCompany.company_folder />
        <cfset application.company_prerefix = thisCompany.company_prefix />

        <cfset application.init = 1>    
</cfif>

It just sets up some basic site wide vars - nothing special. What im
thinking though is that this is just a bad use of the application
scope? Surely i could just use

<cfquery datasource="#variables.dsn#" name="thisCompany"
 cachedWithin="#createTimeSpan(2,0,0,0)#">
        SELECT * 
        FROM companydetails c
        WHERE c.company_folder = '#thisSiteName#'
</cfquery>
<cfset request.companyName = thisCompany.company_name />
<cfset request.companyWebsite = thisCompany.company_website />
<cfset request.companyEmail = thisCompany.company_email />
<cfset request.companyId = thisCompany.company_uid />
<cfset request.companyfolder = thisCompany.company_folder />
<cfset request.company_prerefix = thisCompany.company_prefix />

Which would save the having too much in the app.scope?

Am i missing something obvious? What would/does everyone else do?

Andy J
www.andyjarrett.co.uk





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:218173
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