From a4173dd2e979773f9a65b51c20ef0708ba1474d5 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 8 Dec 2012 02:50:42 +0100 Subject: On simule la pagination pour optimiser les requêtes en BDD (évite de tout charger puis d'en jeter les 3/4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/indexController.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'app/controllers/indexController.php') 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 (); -- cgit v1.2.3