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

Pager should have getTotalResults method function #2954

Closed
crustamet opened this issue May 8, 2020 · 2 comments
Closed

Pager should have getTotalResults method function #2954

crustamet opened this issue May 8, 2020 · 2 comments

Comments

@crustamet
Copy link
Contributor

I am requesting this because it is easy to make.

The problem is when i am using Paginate on model and it makes this query that counts all results from the database.
But i have no option to retrieve the Total Count and have to make another query to get countAllResults again.

So i am duplicating queries because of this.

@crustamet
Copy link
Contributor Author

Code for getTotalResults from Pager

/**
 * Returns the total count of the results.
 *
 * @param string|null $group
 *
 * @return integer
 */

public function getTotalResults(string $group = 'default'): int
{
	$this->ensureGroup($group);
	
	return $this->groups[$group]['total'];
}

This works great Surely as i see the pattern from all other functions

@michalsn
Copy link
Member

We already have the getDetails() method which will return a handful of data as an array - including total number of results.

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

No branches or pull requests

2 participants