fix sql statement for searching when setting a limit

This commit is contained in:
Uwe Steinmann 2019-07-16 20:16:50 +02:00
parent b7417b4ea4
commit e71c9c2e4e

View File

@ -1441,9 +1441,6 @@ class SeedDMS_Core_DMS {
// Prepare the complete search query, including the LIMIT clause. // Prepare the complete search query, including the LIMIT clause.
$searchQuery = "SELECT DISTINCT `tblFolders`.`id` ".$searchQuery." GROUP BY `tblFolders`.`id`"; $searchQuery = "SELECT DISTINCT `tblFolders`.`id` ".$searchQuery." GROUP BY `tblFolders`.`id`";
if($limit) {
$searchQuery .= " LIMIT ".$limit." OFFSET ".$offset;
}
switch($orderby) { switch($orderby) {
case 'dd': case 'dd':
$searchQuery .= " ORDER BY `tblFolders`.`date` DESC"; $searchQuery .= " ORDER BY `tblFolders`.`date` DESC";
@ -1459,6 +1456,10 @@ class SeedDMS_Core_DMS {
default: default:
$searchQuery .= " ORDER BY `tblFolders`.`name`"; $searchQuery .= " ORDER BY `tblFolders`.`name`";
break; break;
}
if($limit) {
$searchQuery .= " LIMIT ".$limit." OFFSET ".$offset;
} }
// Send the complete search query to the database. // Send the complete search query to the database.
@ -1713,11 +1714,12 @@ class SeedDMS_Core_DMS {
$offset -= $totalFolders; $offset -= $totalFolders;
else else
$offset = 0; $offset = 0;
if($limit)
$searchQuery .= " LIMIT ".$limit." OFFSET ".$offset;
$searchQuery .= $orderbyQuery; $searchQuery .= $orderbyQuery;
if($limit)
$searchQuery .= " LIMIT ".$limit." OFFSET ".$offset;
// Send the complete search query to the database. // Send the complete search query to the database.
$resArr = $this->db->getResultArray($searchQuery); $resArr = $this->db->getResultArray($searchQuery);
if($resArr === false) if($resArr === false)