Re: {CodeIgniter Kenya} Remembering Search Results

22 views
Skip to first unread message

Erick Njenga

unread,
Dec 14, 2011, 5:15:07 AM12/14/11
to codeigni...@googlegroups.com
How about saving it in a session?
Sent from my BlackBerry Torch®

Peter Karunyu

unread,
Dec 14, 2011, 5:22:24 AM12/14/11
to codeigni...@googlegroups.com
Saving the search keyword or actual SQL generated or the HTML of the search results?

I though sessions had some sort of limit regarding the amount of data they can store?

Erick Njenga

unread,
Dec 14, 2011, 6:10:54 AM12/14/11
to codeigni...@googlegroups.com

The do have limits and expire after a certain duration so I'd suggest you save the search keyword. The only drawback to that is that you'll have to run the search query again. I think this would be the simplest approach ama?
--  


Thanks and Regards,
Erick Njenga Nyachwaya,
M: +254-725-008-790






Peter Karunyu

unread,
Dec 14, 2011, 8:58:59 AM12/14/11
to codeigni...@googlegroups.com
Yes it seems so. I did read somewhere about CI's capability to cache database results, let me dig into the manual and see if that can help.
--
Regards,
Peter Karunyu
-------------------
Web Performance Evangelist
Make your website and web app faster.

Peter Karunyu

unread,
Dec 15, 2011, 3:13:02 AM12/15/11
to codeigni...@googlegroups.com
Came across a post in the CI forums of a similar question:


The suggestion is:

"... I would rather store the search term in the session and check for it everytime the page is loaded. If the user accesses the page without pagination info, e.g. /search you can reset the term as he probably wants to search for something else. If he navigates back to page x, e.g. /search/x you can use the search term from the session to determine how many search results there are.

Another solution would be to save the performed search in your database and generate a unique key for each search. Then you can just pass the unique key in the url and use that..."

Isaak Mogetutu

unread,
Dec 16, 2011, 6:13:47 AM12/16/11
to codeigni...@googlegroups.com
IMO Saving search term in session or in DB would be the best solution.

Peter Karunyu

unread,
Dec 19, 2011, 8:30:18 AM12/19/11
to codeigni...@googlegroups.com
But then that would mean you run the search query again?

Ndungi Kyalo

unread,
Dec 20, 2011, 1:50:20 AM12/20/11
to codeigni...@googlegroups.com
The saved search term might yield a different result set the next time it is invoked. I think that is why he wants to specificaly remember the search _results_ , rzather than the term that yielded them. I would suggest storing the id's of the result items in an array string; a json object; or in whatever convenient string format for later retrieval. That way, you do get to save a snapshot of the search results for later retrieval and you also save on db space.

my 20 bob :-)

--
Ndungi Kyalo
neno.co.ke ~ Your word O Lord, lights my path.

Peter Karunyu

unread,
Dec 20, 2011, 2:04:53 AM12/20/11
to codeigni...@googlegroups.com
Hadn't seen it that way, getting the primary key's of the search results, saving them somewhere convenient, the running the search query again but this time with the primary keys, which will make the query faster than the first search query...
Reply all
Reply to author
Forward
0 new messages