order global search

This commit is contained in:
yuri
2015-10-20 11:42:16 +03:00
parent 835f95eb52
commit 395063ea35
+9 -1
View File
@@ -95,7 +95,15 @@ class GlobalSearch extends \Espo\Core\Services\Base
$row = $sth->fetch(\PDO::FETCH_ASSOC);
$totalCount = $row['COUNT'];
$unionSql .= " ORDER BY name";
if (count($entityTypeList)) {
$entityListQuoted = [];
foreach ($entityTypeList as $entityType) {
$entityListQuoted[] = $pdo->quote($entityType);
}
$unionSql .= " ORDER BY FIELD(entityType, ".implode(', ', $entityListQuoted)."), name";
} else {
$unionSql .= " ORDER BY name";
}
$unionSql .= " LIMIT :offset, :maxSize";
$sth = $pdo->prepare($unionSql);