public function paginate($RowsPerPage) { // count data $sql = "select count(*) as nbRows from " . $this->name; $var = Database::read($sql); $this->RowsPerPage = $RowsPerPage; $this->nbRows = $var[0]['nbRows']; $this->nbPages = ceil($this->nbRows / $RowsPerPage); //if isset get $this->CurrentPage = 1; if (isset($_GET[Config::get('view.pagination_param')]) && !empty($_GET[Config::get('view.pagination_param')])) { if ($_GET[Config::get('view.pagination_param')] > 0 && $_GET[Config::get('view.pagination_param')] <= $this->nbPages) { $this->CurrentPage = Res::get(Config::get('view.pagination_param')); } } //get Data $r = array(); $sql = "select * from " . $this->name . " Limit " . ($this->CurrentPage - 1) * $this->RowsPerPage . ",{$this->RowsPerPage}"; $this->data = Database::read($sql); // return $this; }