Add a way to specify the number of item per page. re #34
This commit is contained in:
parent
768bccb26c
commit
caa46c50e3
16
base.php
16
base.php
|
@ -851,6 +851,11 @@ abstract class Base
|
||||||
|
|
||||||
private static $db = NULL;
|
private static $db = NULL;
|
||||||
|
|
||||||
|
public static function isMultipleDatabaseEnabled () {
|
||||||
|
global $config;
|
||||||
|
return is_array ($config['calibre_directory']);
|
||||||
|
}
|
||||||
|
|
||||||
public static function getDbList () {
|
public static function getDbList () {
|
||||||
global $config;
|
global $config;
|
||||||
if (is_array ($config['calibre_directory'])) {
|
if (is_array ($config['calibre_directory'])) {
|
||||||
|
@ -902,11 +907,15 @@ abstract class Base
|
||||||
self::$db = NULL;
|
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;
|
global $config;
|
||||||
$totalResult = -1;
|
$totalResult = -1;
|
||||||
|
|
||||||
if (getCurrentOption ("max_item_per_page") != -1 && $n != -1)
|
if (is_null ($numberPerPage)) {
|
||||||
|
$numberPerPage = getCurrentOption ("max_item_per_page");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($numberPerPage != -1 && $n != -1)
|
||||||
{
|
{
|
||||||
// First check total number of results
|
// First check total number of results
|
||||||
$result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter));
|
$result = self::getDb ($database)->prepare (str_format ($query, "count(*)", $filter));
|
||||||
|
@ -915,7 +924,8 @@ abstract class Base
|
||||||
|
|
||||||
// Next modify the query and params
|
// Next modify the query and params
|
||||||
$query .= " limit ?, ?";
|
$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));
|
$result = self::getDb ($database)->prepare(str_format ($query, $columns, $filter));
|
||||||
|
|
Loading…
Reference in a new issue