Skip to content

Commit

Permalink
Fixes SQL query error on sort by last_update
Browse files Browse the repository at this point in the history
  • Loading branch information
oliveratgithub committed Feb 24, 2024
1 parent ba941b3 commit 4c37227
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions www/scripts/tploverview.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,28 @@
global $db, $smarty;

$sort_by = filter_input(INPUT_GET, 'sort', FILTER_DEFAULT, FILTER_REQUIRE_SCALAR) ?? null;
$order_by = filter_input(INPUT_GET, 'order', FILTER_DEFAULT, FILTER_REQUIRE_SCALAR) ?? 'DESC';

switch ($sort_by)
{
case 'tpl':
$sort = 'ORDER BY id';
$sort = 'id';
break;
case 'titel':
$sort = 'ORDER BY title';
$sort = 'title';
break;
case 'word':
$sort = 'ORDER BY word';
$sort = 'word';
break;
case 'owner':
$sort = 'ORDER BY owner';
break;
case 'update':
$sort = 'owner';
break;
case 'update';
default:
$sort = 'ORDER BY last_update'; break;
$sort = 'last_update';
}

$order = $_GET['order'] === 'ASC' ? 'ASC' : 'DESC';
$sort_order = $sort.' '.$order;

$sort_order = sprintf('ORDER BY %s %s', $sort, $order_by);
$e = $db->query('SELECT id, title, word, owner, LENGTH(tpl) size, UNIX_TIMESTAMP(last_update) updated, update_user, read_rights, write_rights FROM templates WHERE del="0" '.$sort_order, __FILE__, __LINE__, 'SELECT All Templates');
$list = [];
$totalsize = 0;
Expand Down

0 comments on commit 4c37227

Please sign in to comment.