also, it's nice to know I was on the right track (or at least one of the right tracks).
This shows me that I have alot of DB language to learn.
> keep what you got with the 24 hour cache... add your tipUsed column to
> the table
>
> when u have a tip to display.. throw an update query in there to flag
> the tipUsed column as used
>
> thats pretty much it :)
>
> so now when the cache expires, the next tip will be grabbed and
> flagged
>
>
> <cfquery name="gettip" datasource="MYDSN" maxrows="1"
> cachedwithin"#CreateTimeSpan(1,0,0,0)#">
> select * from tbl_tips where tipUsed = 0
> </cfquery>
>
> this will grab the first tip that it comes to where TipUsed is 0
>
> now set the tip being used as Used
>
> <!--- If there was no record returned then the table is either empty
> or all tips are set to USED and will need to be reset --->
> <cfif GetTip.RecordCount is 0>
> <!--- Reset all tips to NOT USED --->
> <cfquery name="ResetTips" datasource="MYDSN">
> UPDATE tbl_Tips
> SET TipUsed = 0
> </cfquery>
>
> <!--- after its reset, THEN grab your tip and cache it --->
> <cfquery name="gettip" datasource="MYDSN" maxrows="1"
> cachedwithin"#CreateTimeSpan(1,0,0,0)#">
> select * from tbl_tips where tipUsed = 0
> </cfquery>
>
> </cfif>
>
> <!--- now as long as your table is not empty, you have a tip and can
> set it to USED (TipUsed = 0) --->
> <cfif GetTip.RecordCount NEQ 0>
> <cfquery name="UpdateTip" datasource="MYDSN">
> UPDATE tbl_Tips
> SET TipUsed = 1
> WHERE TipID = #val(GetTip.TipID)#
> </cfquery>
>
> <cfoutput>#GetTip.Tip#</cfoutput>
> </cfif>
>
> ----- Original Message -----
> From: daniel kessler
> To: CF-Talk
> Sent: Wednesday, August 11, 2004 2:02 PM
> Subject: Re: tip of the day
>
>
> ok, I have another TOTD question. I was told that each tip can only
> be displayed once and that they would prefer that I go down the list
> from record 1 to n. When all records are displayed once, then I can
> go through the list again.
>
> I have a thought on a way to do this, but not sure if it's sensible or
> the best way:
>
> 1 - Have a "tip_used" column.
> 2 - Query for a list of unused tips, sorted by their ID field will
> will be an ascending unique number.
> 3 - If the number of unused tips is 0, then go through all the records
> and set them all to unused ( ? )
> 3 - Grab the first tip, get it's ID.
> 4 - Query for that ID and make it a cached query.
>
> and maybe i can put all this in a <cflock> to make it all happen at
> once?
>
> All thoughts are appreciated.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

