Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.9.3, 1.9.4, 1.9.5, 1.9.6
-
Fix Version/s: Next Mini Release
-
Component/s: Zend_Paginator
-
Labels:None
Description
I have a Zend_Db_Select object that does several one-to-many joins on multiple tables. I am passing that select object to view's "paginationControl" helper. The number of rows I get is, for example, 5 but the paginator control's "totalItemCount" property says 11.
Here is some example code:
Zend_Db_Select generation in the controller action
Note ->distinct()
$select = $c->getAdapter()->select()->distinct();
$select->from(array('c' => 'table0'), array(
'*',
));
$select->joinLeft(array('t' => 'table1'),
'c.id = t.id',
array()
);
$select->joinLeft(array('f' => 'table2'),
'c.id = f.id',
array()
);
Then I assign the paginator object to the view:
$paginator = Zend_Paginator::factory($select);
$paginator->setCurrentPageNumber($page);
$paginator->setItemCountPerPage(10);
$this->view->items = $paginator;
After that I'm printing the paginator in the view like this:
$params = array(...); print $this->paginationControl($this->items, Options::PAGINATOR_STYLE, '_pagination.phtml', $params);
And just in case, here's how the counts in the _pagination.phtml are printed:
print 'Showing ' . $this->firstItemNumber . ' - ' . $this->lastItemNumber . ' of ' . $this->totalItemCount . ' results (' . $this->itemCountPerPage . ' per page)';
The output is: "Showing 1 - 5 of 11 results (10 per page)"
To summarize it all - the amount of row objects in the paginator is correct but totalItemCount is not.
Can you add a ->distinct() to your select?