Skip to content

Instantly share code, notes, and snippets.

@alex7r
Created July 1, 2016 13:24
Show Gist options
  • Save alex7r/44996460ce13587b36520e43a59b915f to your computer and use it in GitHub Desktop.
Save alex7r/44996460ce13587b36520e43a59b915f to your computer and use it in GitHub Desktop.
pagination limitation of MySQL Calc found rows
<?php /**
* Method to get the starting number of items for the data set.
*
* @return integer The starting number of items available in the data set.
*
* @since 12.2
*/
public function getStart()
{
$store = $this->getStoreId('getstart');
// Try to load the data from internal storage.
if (isset($this->cache[$store]))
{
return $this->cache[$store];
}
$start = $this->getState('list.start');
$limit = $this->getState('list.limit');
$total = $this->getTotal();
if ($start > $total - $limit)
{
$start = max(0, (int) (ceil($total / $limit) - 1) * $limit);
}
// Add the total to the internal cache.
$this->cache[$store] = $start;
return $this->cache[$store];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment