From caa46c50e3310294275f56d0e2388a207228817d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Fri, 22 Nov 2013 14:36:39 +0100 Subject: [PATCH] Add a way to specify the number of item per page. re #34 --- base.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/base.php b/base.php index dc08517..a3ccdad 100644 --- a/base.php +++ b/base.php @@ -850,6 +850,11 @@ abstract class Base const COMPATIBILITY_XML_ALDIKO = "aldiko"; private static $db = NULL; + + public static function isMultipleDatabaseEnabled () { + global $config; + return is_array ($config['calibre_directory']); + } public static function getDbList () { global $config; @@ -902,11 +907,15 @@ abstract class Base self::$db = NULL; } - public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL) { + public static function executeQuery($query, $columns, $filter, $params, $n, $database = NULL, $numberPerPage = NULL) { global $config; $totalResult = -1; + + if (is_null ($numberPerPage)) { + $numberPerPage = getCurrentOption ("max_item_per_page"); + } - if (getCurrentOption ("max_item_per_page") != -1 && $n != -1) + if ($numberPerPage != -1 && $n != -1) { // First check total number of results $result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter)); @@ -915,7 +924,8 @@ abstract class Base // Next modify the query and params $query .= " limit ?, ?"; - array_push ($params, ($n - 1) * getCurrentOption ("max_item_per_page"), getCurrentOption ("max_item_per_page")); + + array_push ($params, ($n - 1) * $numberPerPage, $numberPerPage); } $result = self::getDb ($database)->prepare(str_format ($query, $columns, $filter));