Krótkie mam pytanie, otóż czy dobrze napisałem ten kod? Co tu może być błędnego? Jak powinien wyglądać konstruktor?
Kod PHP:
<? class Pagination { private $perPage = 0; private $countRecords = 0; private $page; private $from; private $startLimit = 0; private $val; private $min; private $max; public function __construct($current = null, $limit = null, $startLimit = null) { $this->page = (int)$current; $this->perPage = (int)$limit; $this->startLimit = (int)$startLimit; } private function displayResults($val, $min, $max) { return ($val >= $min && $val <= $max); } private function onPage($perPage) { return $perPage; } private function page() { { $page = $_GET['page']; } else { $page += 1; } return $page; } private function startLimit() { $startLimit = ($this->page() * $this->onPage(30)) - $this->onPage(30); return $startLimit; } private function dataSelect($from) { return $row['total']; } private function firstPage() { return 1; } private function lastPage() { return $allPages; } private function currentPage() { return $this->page(); } private function previousPage() { if($this->page() > 1) { return '<a href="' . $_SERVER['PHP_SELF'] . '?page='.($this->currentPage() - 1).'">< poprzednia</a>'; } else { return false; } } private function nextPage() { if($this->page() != $this->lastPage()) { return '<a href="' . $_SERVER['PHP_SELF'] . '?page='.($this->currentPage() + 1).'">nastepna ></a>'; } else { return false; } } public function allPages() { if($this->page() > 4) { } for($i = 1; $i <= $this->lastPage(); $i++) { if($this->displayResults($i, ($this->page() - 3), ($this->page() + 5))) if($_GET['page'] == $i) { } else { } } if($this->lastPage() != $this->currentPage()) { } else { return false; } } public function rowsLimit() { return 'LIMIT ' . $this->startLimit() . ', ' . $this->onPage(30) . ''; } }