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

Implementing pagination? #220

Open
charlesswanson opened this issue Jan 20, 2017 · 6 comments
Open

Implementing pagination? #220

charlesswanson opened this issue Jan 20, 2017 · 6 comments

Comments

@charlesswanson
Copy link

I have a select query which limits the results to a count of 10.
In raw mysqli, I can have
"SELECT SQL_CALC_FOUND_ROWS * FROM table WHERE condition LIMIT 0,10", then perform another query to know how many total rows matched.
SELECT FOUND_ROWS() as foundrows

It looks like doctrine supports something similar: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/pagination.html

Is this possible with spot2?

Thanks

@nebulousGirl
Copy link
Contributor

There is nothing similar in Spot, but you could write a class that makes use of a Spot Query.

Spot aims to be a more lightweight alternative. So, I don't think that kind of class would make it to the core.

You can paginate your query yourself using limit(), offset() and count()

@marcelloh
Copy link

marcelloh commented Jan 26, 2017

Which seems a strange asnwer, because I have this working in my code:

if ($limit)
{
	$result = $this->where($aFilter)
		->order(['name' => 'ASC'])
		->limit($limit, $offset);
}
else
{
	$result = $this->where($aFilter)
		->order(['name' => 'ASC']);
}

@tuupola
Copy link
Contributor

tuupola commented Jan 26, 2017

@marcelloh Which is exactly what @nebulousGirl answered.

You can paginate your query yourself using limit(), offset() and count()

Question was if Spot has is a Doctrine style paginator. Which Spot does not have.

@vlucas
Copy link
Collaborator

vlucas commented Jan 27, 2017

Honestly I would not be opposed to a simplistic Pagination class that uses the built-in limit() offset() and count() methods to make things easier.

@tuupola
Copy link
Contributor

tuupola commented Feb 19, 2017

I did something like that a while ago.

https://github.com/tuupola/beeper

@tuupola
Copy link
Contributor

tuupola commented Mar 31, 2017

Personally I do not think this belongs in core. However thanks to being an organisation we could make something like spotorm/paginator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants