Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added totalCount config to Phalcon\Paginator\Adapter\QueryBuilder #12041

Closed
wants to merge 1 commit into from

Conversation

Izopi4a
Copy link
Member

@Izopi4a Izopi4a commented Jul 27, 2016

I guess situations like this https://forum.phalconphp.com/discussion/12207/how-to-alter-count-logic-in-querybuilderpaginator in some high complex application, are highly possible.

With this patch developers can specify the exact number of total results ( by performing a query of their own before that ) without build-ed in counter being fired.

Maybe another plus of this patch is sometimes people wants to count id, instead of *, with this patch they can do it the way they want without any dramatic changes to the framework itself.

//other ideas:
It can be done by checking if the given value is_numeric, otherwise people can specify raw queries, or pass another builder, but i think it might end up being an overkill.

example usage :

use Phalcon\Paginator\Adapter\QueryBuilder;

$paginator = new QueryBuilder(
    [
        'builder'    => $builder,
        'limit'      => 20,
        'page'       => $currentPage,
        'totalCount' => $counterQuery->execute()->total_rows
   ]
);

@Izopi4a Izopi4a force-pushed the PaginatorTotalCount branch 2 times, most recently from 2a1394a to a848962 Compare July 27, 2016 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants