mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-3207: Paginator does not count according to query max results #3973
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Jul 5, 2014).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user draeli:
I use
Doctrine\ORM\Tools\Pagination\Paginatorto have an paginate object and use like this :In this case when I do a count on object result and have "int 2" in spite I expected "int 1".
I look the class and find may be the problem, why there is this ?
in "count" method.
If I remove this line, expected result appear.
@doctrinebot commented on GitHub (Jul 6, 2014):
Comment created by @ocramius:
The paginator will always count over the entire resultset of your query, since that is its primary purpose together with providing iteration over slices of the resultset.
@doctrinebot commented on GitHub (Jul 6, 2014):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Jul 6, 2014):
Comment created by draeli:
I can understand the global count but for example (and now I saw why the line I descripbe above is) in case I use with Twig for iterate (with {% for %} syntax), the length return by object|length not appear to be what expected because if the goal of Pagination is to expose method to work more easier with object, I supose you must only work with current page object result and the total count must be expose in method but not directly as iterator count result.
@doctrinebot commented on GitHub (Jul 6, 2014):
Comment created by @ocramius:
[~draeli] the
count($paginator)will give you the total items. The current offset and limit can be trusted to get the items in the current page.@doctrinebot commented on GitHub (Jul 6, 2014):
Comment created by draeli:
I understood about the count($paginator) but that's not the only point.
Why when I do
loop.last(inside for loop) this give me "false" in spite it is the last one for the current page ?Sorry to insist but as simple user of Sf2/Twig/Doctrine I don't understand this logic :/
(or maybe I'm not enough clear)
@doctrinebot commented on GitHub (Jul 6, 2014):
Comment created by draeli:
To explain more, actually I do a request and give me object :
and in the view
As you see something is not expected.
@doctrinebot commented on GitHub (Jul 6, 2014):
Comment created by @ocramius:
We can't provide support for Twig integration. That seems to be a Twig specific issue with how twig deals with loops, nothing related with the ORM. Instead, ask on http://stackoverflow.com/
@doctrinebot commented on GitHub (Jul 6, 2014):
Comment created by draeli:
Ok thank you for your answer, I'm going to ask, just I signal I put question relative to this for Twig here :
https://github.com/symfony/symfony/issues/11316
Have a good day :)
@doctrinebot commented on GitHub (Jul 7, 2014):
Comment created by stof:
Iterate over
paginator.iteratorin Twig, andloop.lastwill give you wht you want@doctrinebot commented on GitHub (Jul 8, 2014):
Comment created by draeli:
A really big thank you Christophe :) It's work :D