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

@@ -680,6 +680,23 @@ class Asset
FROM assets');
}
public static function getOffset($offset, $limit, $order, $direction)
{
return Registry::get('db')->queryAssocs('
SELECT a.id_asset, a.subdir, a.filename,
a.image_width, a.image_height, a.mimetype,
u.id_user, u.first_name, u.surname
FROM assets AS a
LEFT JOIN users AS u ON a.id_user_uploaded = u.id_user
ORDER BY {raw:order}
LIMIT {int:offset}, {int:limit}',
[
'order' => $order . ($direction == 'up' ? ' ASC' : ' DESC'),
'offset' => $offset,
'limit' => $limit,
]);
}
public function save()
{
if (empty($this->id_asset))