private function paginate($page, $fields = null)
{
$this->db->pageLimit = self::$pageLimit;
$res = $this->db->paginate($this->dbTable, $page, $fields);
self::$totalPages = $this->db->totalPages;
if ($this->db->count == 0) {
return null;
}
foreach ($res as &$r) {
$this->processArrays($r);
$this->data = $r;
$this->processAllWith($r, false);
if ($this->returnType == 'Object') {
$item = new static($r);
$item->isNew = false;
$objects[] = $item;
}
}
$this->_with = array();
if ($this->returnType == 'Object') {
return $objects;
}
if ($this->returnType == 'Json') {
return json_encode($res);
}
return $res;
}