I find it easier and simpler to put the query in request scope in the first 
place (not really necessary) and cache it.  That way, none of the below is 
necessary.

best,  paul

At 09:27 AM 5/11/01 -0400, you wrote:
>And to wrap it all up
>
>You want to write the query in a persistent scope.  But since every time you
>write to or access a persistent scope you must lock the access, you want to
>copy the query to the request scope in the application.cfm.  This way you
>will only nead to bother with the locking process when creating the query
>and copying to the request scope.  Everywhere else in your site you'll call
>the request variable to access the query info... and you won't have to use a
>lock.
>
>so your application.cfm would look something like this.
>
><!--- Create the query in a persistent scope --->
><cflock  scope="APPLICATION" throwontimeout="No" timeout="1"
>type="EXCLUSIVE">
>         <cfif NOT isdefined("application.myquery")>
>                 <cfquery name="application.myquery" datasource="mydsn">
>                         [SQL Stuff]
>                 </cfquery>
>         </cfif>
></cflock>
>
><!--- Copy the query to the request scope --->
><cflock scope="APPLICATION" throwontimeout="No" timeout="1" type="READONLY">
>         <cfset request.myquery = duplicate(application.myquery)>
></cflock>
>
>|-----Original Message-----
>|From: Sean Daniels [mailto:[EMAIL PROTECTED]]
>|Sent: Thursday, May 10, 2001 10:54 AM
>|To: CF-Talk
>|Subject: Re: structure in request scope
>|
>|
>|On 5/10/01 1:59 AM Mark Ireland wrote:
>|
>|> Could someone tell me how to load a structure into the
>|request scope in the
>|> application.cfm
>|>
>|> once only when a user first visits a page. That is, check that the
>|> structure is there and dont rerun the query code if it is
>|>
>|> unless a change has been made to the database.
>|
>|It sounds like you want to put the structure into a persistent
>|scope, which
>|request is not. Use the application scope instead if it is
>|global to all
>|users. If not, client or session scope.
>|
>|<cfif isdefined("application.strFoo")>
>|    <cflock type="exclusive" scope="application" name="strLock">
>|        <cfset application.strFoo = structnew()>
>|        <!--- etc --->
>|    </cflock>
>|</cfif>
>|
>|
>|- Sean
>|
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to