-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG] Incorrect results from Phalcon\Paginator\Adapter\Model #1654
Comments
<?php
function dump_page($page)
{
foreach ($page->items as $key => $item) {
$page->items[$key] = $item->cedula;
}
print_r($page);
}
class Personnes extends Phalcon\Mvc\Model {}
$di = new Phalcon\DI();
$di->set('modelsManager', function() { return new Phalcon\Mvc\Model\Manager(); });
$di->set('modelsMetadata', function() { return new Phalcon\Mvc\Model\Metadata\Memory(); });
$di->set('db', function() { require 'unit-tests/config.db.php'; return new Phalcon\Db\Adapter\Pdo\Mysql($configMysql); });
$personnes = Personnes::find(array('order' => 'cedula'));
$paginator = new Phalcon\Paginator\Adapter\Model(array(
'data' => $personnes,
'limit' => 10,
'page' => 1
));
dump_page($paginator->setCurrentPage(1)->getPaginate());
dump_page($paginator->setCurrentPage(218)->getPaginate());
dump_page($paginator->setCurrentPage(219)->getPaginate());
dump_page($paginator->setCurrentPage(220)->getPaginate()); Output:
Page 219 does not return anything, page 220 misses the very first element. |
ghost
mentioned this issue
Dec 8, 2013
Merged
phalcon
pushed a commit
that referenced
this issue
Dec 9, 2013
ghost
mentioned this issue
Dec 10, 2013
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test case:
When current page is 5 the output looks like this:
What is wrong:
items
must contain 0, not 1 (I must say it is a bit awkward that it isvalid()
method that is supposed to move forward the data pointer, notnext()
)current
is set to 1, why isnext
set to 4?The text was updated successfully, but these errors were encountered: