public function listRows($collection)
{
foreach ($this->sort as $key => $val) {
//cast vals to int
$sort[$key] = (int) $val;
}
$col = $this->mongo->selectCollection($collection);
$this->count = $col->count();
$cur = $col->find()->sort($sort);
if ($_SESSION['limit'] && $this->count > $_SESSION['limit']) {
if ($this->count > 1) {
$this->colKeys = phpMoAdmin::getArrayKeys($col->findOne());
}
$cur->limit($_SESSION['limit']);
if (isset($_GET['skip'])) {
if ($this->count <= $_GET['skip']) {
$_GET['skip'] = $this->count - $_SESSION['limit'];
}
$cur->skip($_GET['skip']);
}
} else {
if ($this->count > 1) {
$this->colKeys = phpMoAdmin::getArrayKeys($cur->getNext());
}
}
if ($this->count > 1) {
$curLast = $col->find()->sort($sort);
if ($this->count > 2) {
$curLast->skip(min($this->count, 100) - 1);
}
$this->colKeys = array_merge($this->colKeys, phpMoAdmin::getArrayKeys($curLast->getNext()));
ksort($this->colKeys);
}
return $cur;
}