Management controllers: move table queries into models

This commit is contained in:
2025-01-08 17:17:53 +01:00
parent 2d2ef38422
commit cc0ff71ef7
10 changed files with 144 additions and 156 deletions

View File

@@ -33,4 +33,20 @@ class ErrorLog
SELECT COUNT(*)
FROM log_errors');
}
public static function getOffset($offset, $limit, $order, $direction)
{
assert(in_array($order, ['id_entry', 'file', 'line', 'time', 'ipaddress', 'id_user']));
return Registry::get('db')->queryAssocs('
SELECT *
FROM log_errors
ORDER BY {raw:order}
LIMIT {int:offset}, {int:limit}',
[
'order' => $order . ($direction === 'up' ? ' ASC' : ' DESC'),
'offset' => $offset,
'limit' => $limit,
]);
}
}