Teng::Plugin::SearchBySQLAbstractMore::Pager::Count - pager plugin using SQL::AbstractMore. count total entry by count(*)
see Teng::Plugin::SearchBySQLAbstractMore
This solution is bad when you have many records. You re-consider the implementation where you want to use this module. If you are using MySQL, I recommend to use Pager::CountOrMySQLFoundRows or Pager::MySQLFoundRows.
search_by_sql_abstract_more with paging feature. additional parameter can be taken, page, rows and hint_columns.
search_by_sql_abstract_more
page
rows
hint_columns
If you pass hint_columns, or -hint_columns as option and select using "GROUP BY", it uses these values as select columns for calculating total count.
-hint_columns
For example:
my ($rows, $pager) = $teng->search_by_sql_abstrat_more_with_pager ('clicks', {}, {-columns => [qw/user_id count(*) date(clicked_datetime)/], -group_by => [qw/user_id date(clicked_datetime)/], -rows => 20, -page => 1, } );
It execute the following 2 SQLs.
SELECT COUNT(*) AS cnt FROM (SELECT user_id,DATE(clicked_datetime),COUNT(*) FROM clicks GROUP BY user_id, date(clicked_datetime)) AS total_count; SELECT user_id, date(clicked_datetime), COUNT(*) FROM clicks GROUP BY user_id, date(clicked_datetime) LIMIT 20 OFFSET 0;
If you pass -hint_columns option.
my ($rows, $pager) = $teng->search_by_sql_abstrat_more_with_pager ('clicks', {}, {-columns => [qw/user_id count(*) date(clicked_datetime)/], -group_by => [qw/user_id date(clicked_datetime)/], -hint_columns => [qw/user_id/], -rows => 20, -page => 1, } );
SELECT COUNT(*) AS cnt FROM (SELECT user_id FROM clicks GROUP BY user_id, date(clicked_datetime)) AS total_count; SELECT user_id,date(clicked_datetime) FROM clicks GROUP BY user_id, date(clicked_datetime) LIMIT 20 OFFSET 0;
Ktat, <ktat at cpan.org>
<ktat at cpan.org>
Please report any bugs or feature requests to bug-teng-plugin-searchbysqlabstractmore at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Teng-Plugin-SearchBySQLAbstractMore. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-teng-plugin-searchbysqlabstractmore at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Teng::Plugin::SearchBySQLAbstractMore
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Teng-Plugin-SearchBySQLAbstractMore
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Teng-Plugin-SearchBySQLAbstractMore
CPAN Ratings
http://cpanratings.perl.org/d/Teng-Plugin-SearchBySQLAbstractMore
Search CPAN
http://search.cpan.org/dist/Teng-Plugin-SearchBySQLAbstractMore/
Copyright 2012 Ktat.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Teng::Plugin::SearchBySQLAbstractMore, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Teng::Plugin::SearchBySQLAbstractMore
CPAN shell
perl -MCPAN -e shell install Teng::Plugin::SearchBySQLAbstractMore
For more information on module installation, please visit the detailed CPAN module installation guide.