Get the first id that is larger than the id of the tip with the latest
date
If this doesn't exist, get the tip with the smallest id
Update the selected tip with today's date
Store the date and tip in the application scope
If the date in the application scope is less than today's date or there
is no tip, start the procedure again
Pascal
> -----Original Message-----
> From: daniel kessler [mailto:[EMAIL PROTECTED]
> Sent: 11 August 2004 20:03
> To: CF-Talk
> 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.
>
>
> > http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/appfra29.htm
> >
> > it will cache it for everyone, its a server side cache
>
> > ----- Original Message -----
>
> > From: daniel kessler
>
> > To: CF-Talk
>
> > Sent: Wednesday, August 04, 2004 3:59 PM
>
> > Subject: Re: tip of the day
> >
> >
>
> > So by caching the query, it assures that everyone gets the same
random
> > TIP for the day or just that particular machine?
> >
>
> > > well there are a couple of ways to get a random record...
>
> > > as long as ou are not using access there is a RAND() function to
do
> > it...
>
> > >
>
> > > something like this if i remember correctly
>
> > >
>
> > > select * from table order by Rand() limit 1
>
> > >
>
> > > that SHOULD return 1 random record everytime its ran.
>
> > >
>
> > > you could also get all of the IDs from the table and then select a
>
> > > radom ID from the #ValueList(QueryName.QueryColumn)# variable
>
> > >
>
> > > like...
>
> > > <cfquery name="IDs" datasource="datasource">
>
> > > select ID from table
>
> > > </cfquery>
>
> > >
>
> > > <cfset randomID = listGetAt(valuelist(IDs.ID), RandRange(1,
>
> > > listlen(Valuelist(IDs.ID)))>
>
> > >
>
> > > then just select * from table where ID = #val(randomid)#
>
> > >
>
> > >
>
> > > the caching part is easy, it is an attribute of the cfquery tag
and
> > as
>
> > > long as its not cleared or the server rebooted, or CF services
>
> > > restarted, then it should last the full cached duration...
>
> > >
>
> > > for 24 hours...
>
> > >
>
> > > <cfquery name="QueryName" datasource="datasourcename"
>
> > > cachedwithin="#createtimespan(0,24,0,0)#">
>
> > > select whatever
>
> > > </cfquery>
>
> > >
>
> > >
>
> > > ** CreateTimeSpan(Days,Hours,Minutes,Seconds)
>
> > >
>
> > >
>
> > >
>
> >
>
> > > ----- Original Message -----
>
> >
>
> > > From: daniel kessler
>
> >
>
> > > To: CF-Talk
>
> >
>
> > > Sent: Tuesday, August 03, 2004 1:36 PM
>
> >
>
> > > Subject: Re: tip of the day
>
> > >
>
> > >
>
> >
>
> > > > Id stick with ID and tip, pull a random one each time and cache
> > the
>
> > >
>
> >
>
> > > > query for 24 hours.
>
> > >
>
> >
>
> > > That brings up some questions. So, I pull a random tip each day,
> > not
>
> > > a random tip each page refresh. So what pulls the random tip and
> > sets
>
> > > it as the TOTD? I've also not yet looked into caching queries.
> > ugh
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

