mirror of
https://github.com/silverstripe/silverstripe-postgresql
synced 2024-10-22 15:05:45 +00:00
Merge pull request #33 from PapaBearNZ/search-engine-patch-1.1
FIX Total Items count on Search
This commit is contained in:
commit
606879243a
@ -1886,12 +1886,14 @@ class PostgreSQLDatabase extends SS_Database {
|
||||
|
||||
$fullQuery = "SELECT * FROM (" . implode(" UNION ", $tables) . ") AS q1 $orderBy LIMIT $limit OFFSET $offset";
|
||||
|
||||
// Get the total items in this search
|
||||
$totalItemsQuery = "SELECT COUNT(*) AS totalitems FROM (" . implode(" UNION ", $tables) . ") AS q1";
|
||||
$totalCount = DB::query($totalItemsQuery);
|
||||
|
||||
// Get records
|
||||
$records = DB::query($fullQuery);
|
||||
$totalCount=0;
|
||||
foreach($records as $record){
|
||||
$objects[] = new $record['ClassName']($record);
|
||||
$totalCount++;
|
||||
}
|
||||
|
||||
if(isset($objects)) $results = new ArrayList($objects);
|
||||
@ -1900,7 +1902,7 @@ class PostgreSQLDatabase extends SS_Database {
|
||||
$list->setLimitItems(false);
|
||||
$list->setPageStart($start);
|
||||
$list->setPageLength($pageLength);
|
||||
$list->setTotalItems($totalCount);
|
||||
$list->setTotalItems($totalCount->value());
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user