NYCPHP Meetup

NYPHP.org

[nycphp-talk] Paging Strategies

Jeff Siegel jeffmailings99 at verizon.net
Fri Oct 19 10:34:01 EDT 2007


Two sources of code:

1. EZSql (if you are using that library) has a library for paging.
2. PHP Cookbook has some code you can use. There's lots of other good stuff
in there too.

Jeff

-----Original Message-----
From: talk-bounces at lists.nyphp.org
[mailto:talk-bounces at lists.nyphp.org]On Behalf Of Dell Sala
Sent: Thursday, October 18, 2007 3:06 PM
To: NYPHP Talk
Subject: [nycphp-talk] Paging Strategies


Every time I implement paging for search results I end up using
different approaches, but I'm never happy with any of them. Am I
missing a simpler, more "correct" solution here? Here's what I've tried:


1) TWO-QUERY APPROACH

on every page view:

- step 1: execute search query with a "SELECT count(*) " to get the
total record count

- step 2: run the search again with the appropriate LIMIT clause to
retrieve the records I need for the current page



2) ONE QUERY, SEEK TO RESULTS

on every page view:

- step 1: execute search query

- step 2: use *_data_seek() to move to the right slice of results for
the current page



3) ONE QUERY, CACHE EVERYTHING

on the first page view:

- execute search query, fetch all results, and cache them

on every other page view:

- retrieve the right slice of results from the cache




-- Dell


_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php





More information about the talk mailing list