events view server pagination - fix sorting name & monitor

This commit is contained in:
Andrew Bauer 2020-10-25 10:40:29 -05:00
parent cb073950b9
commit e9b71b4ce1
1 changed files with 3 additions and 2 deletions

View File

@ -164,9 +164,10 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim
if ( $where )
$where = ' WHERE '.$where;
$sort = $sort == "Name" ? 'M.'.$sort : 'E.'.$sort;
$sort = $sort == "Monitor" ? 'M.Name' : 'E.'.$sort;
$col_str = 'E.*, M.Name AS Monitor';
$query['sql'] = 'SELECT ' .$col_str. ' FROM `' .$table. '` AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'.$where.' ORDER BY LENGTH(' .$sort. '), ' .$sort. ' ' .$order. ' LIMIT ?, ?';
//$query['sql'] = 'SELECT ' .$col_str. ' FROM `' .$table. '` AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'.$where.' ORDER BY LENGTH(' .$sort. '), ' .$sort. ' ' .$order. ' LIMIT ?, ?';
$query['sql'] = 'SELECT ' .$col_str. ' FROM `' .$table. '` AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'.$where.' ORDER BY ' .$sort. ' ' .$order. ' LIMIT ?, ?';
array_push($query['values'], $offset, $limit);
ZM\Warning('Calling the following sql query: ' .$query['sql']);