Jump to content

Total records without pagination; Display queries


bpz
 Share

Recommended Posts

Hi guys,

I am using my own pagination.

I need a COUNT(*) query matching selector params. I found a count() method  in another thread.

$pages->find(template=name, start=0, limit=10);
$pages->count(template=name);

Does this count() make a COUNT(*) query, or does it load everything?

:)

Is it possible to display SQL queries that PW makes? Or even better, display SQL queries for specific selector calls?

Link to comment
Share on other sites

So long as you use limit=n, where n is some number greater than 1, PW will not load any more than n pages (or select the data from mysql). So paginating your selects is a good idea. The getTotal() method from the returned PageArray will contain the total number of found results (the total that would exist had there never been a limit). So the $pages->count() does little more than add a limit=2 to your selector and just returns the result of the $results->getTotal(). That count method is more for syntactic convenience, as PW already counts anything that goes through a find(limit>1). And the instances of where one would use pages->count() are pretty rare. But optimizing the count method to load 0 rather than 2 pages is on my to do list. I'm typing on a cell phone so somewhat limited in my response here, but to recap, everything you need to paginate is already included anytime you include a limit=n in your selector and using PW's pagination is recommended, especially when dealing with large data sets. There is obvious overhead relative to pure SQL queries, but I think it's very much worth it 99% of the time for the sites we build. Enable debug mode in your config.php to see the queries (from admin).

Link to comment
Share on other sites

I don't see it here but got an email about paginator get vars. Make sure you turn on 'allow page numbers' in your template settings because pagination requires that setting to work properly. It shouldn't use get vars for the page number.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...