Skip to content

Commit

Permalink
Add feature to move an item to a specified rank
Browse files Browse the repository at this point in the history
  • Loading branch information
Hicham Benjelloun committed Aug 2, 2017
1 parent 15ba8e0 commit bf41771
Show file tree
Hide file tree
Showing 9 changed files with 1,947 additions and 2,081 deletions.
20 changes: 20 additions & 0 deletions lodel/scripts/Ranks.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,24 @@ public static function getRank($db, $table, $id) {

return (int) $db->GetOne($sqlQuery);
}

public static function getNextRank($db, $table, $parentId, $rank) {
$sqlQuery =
"SELECT rank " .
"FROM {$table} " .
"WHERE rank > {$rank} " .
"AND idparent = {$parentId}";

return (int) $db->GetOne($sqlQuery);
}

public static function getPreviousRank($db, $table, $parentId, $rank) {
$sqlQuery =
"SELECT rank " .
"FROM {$table} " .
"WHERE rank < {$rank} " .
"AND idparent = {$parentId}";

return (int) $db->GetOne($sqlQuery);
}
}
Loading

0 comments on commit bf41771

Please sign in to comment.