diff options
| author | 2012-12-08 02:50:42 +0100 | |
|---|---|---|
| committer | 2012-12-08 02:50:42 +0100 | |
| commit | a4173dd2e979773f9a65b51c20ef0708ba1474d5 (patch) | |
| tree | bba54686152793b0d4dae1bca721384c9f1b4da2 /app/controllers/indexController.php | |
| parent | adc704c3d75518fd7ed7a32b9ed21d9b7eb71c99 (diff) | |
On simule la pagination pour optimiser les requêtes en BDD (évite de tout charger puis d'en jeter les 3/4)
Diffstat (limited to 'app/controllers/indexController.php')
| -rwxr-xr-x | app/controllers/indexController.php | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index 4002a0032..b06b6c711 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -10,6 +10,11 @@ class indexController extends ActionController { $entryDAO = new EntryDAO (); $catDAO = new CategoryDAO (); + // pour optimiser + $page = Request::param ('page', 1); + $entryDAO->_nbItemsPerPage ($this->view->conf->postsPerPage ()); + $entryDAO->_currentPage ($page); + $default_view = $this->view->conf->defaultView (); $mode = Session::param ('mode'); if ($mode == false) { @@ -51,18 +56,7 @@ class indexController extends ActionController { $entries = $entryDAO->listEntries ($mode, $order); } - // Gestion pagination - try { - $page = Request::param ('page', 1); - $this->view->entryPaginator = new Paginator ($entries); - $this->view->entryPaginator->_nbItemsPerPage ($this->view->conf->postsPerPage ()); - $this->view->entryPaginator->_currentPage ($page); - } catch (CurrentPagePaginationException $e) { - Error::error ( - 404, - array ('error' => array ('La page que vous cherchez n\'existe pas')) - ); - } + $this->view->entryPaginator = $entryDAO->getPaginator ($entries); $this->view->cat_aside = $catDAO->listCategories (); $this->view->nb_favorites = $entryDAO->countFavorites (); |
