Skip to main content
Participant
June 28, 2006
Answered

Recordset is M.I.A.

I have two pages... a SEARCH.cfm and a RESULTS.cfm

On the search page I have the form with an action pointing to the results page 'on submit'... Ok to here!

On the results page I display the first 5 records from the recordset and then give the navigation to view more of the recordset... Ok to here! ( ie: Displaying records 1 - 5 of 14 "Next Page Link" " Last Page Link" ) [using the built in CF Navigation code created by Dreamweaver with a little modification]

But here's where the problem comes in... when I press "Next Page" I lose the recordset I searched for and get the complete default recordset for the entire query (ie: Browse All) but records 6 - 10 now!
In my debug, I can see that on any page after page 1, my form variables are set to the default parameters I specified.

To solve this problem, I could re-run the query on each page by passing the variables from my search form page to each page on my results loop... But is there any other way?? I can see a problem down the road when the data and transaction frequency increase... I don't want to call the SERVER over and over again for that query/stored procedure.

So is my only option to re-run that query on each results page? After 2 days of Google-ing... I'm spent... help!!!
This would be so handy to just send a recordset results object or something.
This topic is closed to new replies. Start a new post to keep the conversation going.
Newsgroup_UserCorrect answer
Inspiring
June 28, 2006
You want to look into using the persistent scopes for this. It is what
they are made for, the three main scopes are Server, Application, Session.

Server scoped variables (server.aVar) are accessible by all cfml code on
the same ColdFusion server.

Application scoped variables (application.aVar) are accessible by all
cfml code in the same application.

Session scoped variables (session.aVar) are accessible to all cfml code
running in the same session of the same application. This is most
likely the one you want.

To use session and application variables, you must use a <cfapplication
...> tag to define an application and turn on session management.

Then in your form action page you can do something like
<cfset session.searchForm = duplicate(form)>

Then after that you can refer to all your form varialbes like this
session.searchFrom.aFieldOne and session.searchForm.aFieldTwo. These
variables will exist until the user session ends and each user will have
their own session scope.

There are occasional issues with this, but if you are not doing anything
strange with your CF setup, you should not experience these problems.


jboyus wrote:
> I have two pages... a SEARCH.cfm and a RESULTS.cfm
>
> On the search page I have the form with an action pointing to the results page
> 'on submit'... Ok to here!
>
> On the results page I display the first 5 records from the recordset and then
> give the navigation to view more of the recordset... Ok to here! ( ie:
> Displaying records 1 - 5 of 14 "Next Page Link" " Last Page Link" )
> [using the built in CF Navigation code created by Dreamweaver with a little
> modification]
>
> But here's where the problem comes in... when I press "Next Page" I lose the
> recordset I searched for and get the complete default recordset for the entire
> query (ie: Browse All) but records 6 - 10 now!
> In my debug, I can see that on any page after page 1, my form variables are
> set to the default parameters I specified.
>
> To solve this problem, I could re-run the query on each page by passing the
> variables from my search form page to each page on my results loop... But is
> there any other way??
I can see a problem down the road when the data and
> transaction frequency increase... I don't want to call the SERVER over and over
> again for that query/stored procedure.
>
> So is my only option to re-run that query on each results page? After
> 2 days of Google-ing... I'm spent... help!!!
> This would be so handy to just send a recordset results object or something.
>

5 replies

Inspiring
June 28, 2006
You can cache any query but since you would have to preserve some other variables anyhow, making the query a session variable gives you the same result with less code.

That would be my apporoach.
Translate
Newsgroup_UserCorrect answer
Inspiring
June 28, 2006
You want to look into using the persistent scopes for this. It is what
they are made for, the three main scopes are Server, Application, Session.

Server scoped variables (server.aVar) are accessible by all cfml code on
the same ColdFusion server.

Application scoped variables (application.aVar) are accessible by all
cfml code in the same application.

Session scoped variables (session.aVar) are accessible to all cfml code
running in the same session of the same application. This is most
likely the one you want.

To use session and application variables, you must use a <cfapplication
...> tag to define an application and turn on session management.

Then in your form action page you can do something like
<cfset session.searchForm = duplicate(form)>

Then after that you can refer to all your form varialbes like this
session.searchFrom.aFieldOne and session.searchForm.aFieldTwo. These
variables will exist until the user session ends and each user will have
their own session scope.

There are occasional issues with this, but if you are not doing anything
strange with your CF setup, you should not experience these problems.


jboyus wrote:
> I have two pages... a SEARCH.cfm and a RESULTS.cfm
>
> On the search page I have the form with an action pointing to the results page
> 'on submit'... Ok to here!
>
> On the results page I display the first 5 records from the recordset and then
> give the navigation to view more of the recordset... Ok to here! ( ie:
> Displaying records 1 - 5 of 14 "Next Page Link" " Last Page Link" )
> [using the built in CF Navigation code created by Dreamweaver with a little
> modification]
>
> But here's where the problem comes in... when I press "Next Page" I lose the
> recordset I searched for and get the complete default recordset for the entire
> query (ie: Browse All) but records 6 - 10 now!
> In my debug, I can see that on any page after page 1, my form variables are
> set to the default parameters I specified.
>
> To solve this problem, I could re-run the query on each page by passing the
> variables from my search form page to each page on my results loop... But is
> there any other way??
I can see a problem down the road when the data and
> transaction frequency increase... I don't want to call the SERVER over and over
> again for that query/stored procedure.
>
> So is my only option to re-run that query on each results page? After
> 2 days of Google-ing... I'm spent... help!!!
> This would be so handy to just send a recordset results object or something.
>
Translate
jboyusAuthor
Participant
June 28, 2006
I love it... solution found! thanks to all
Translate
jboyusAuthor
Participant
June 28, 2006
Yeah... that's what I was afraid of.

Can you only cache the query for a specific user/session id?

...And do you mean make the query a session variable?

Thanks for your response
Translate
Inspiring
June 28, 2006
You can either cache the query or make it a session variable.
Translate