Ejemplo n.º 1
0
 function Problem_MoveDown($contest_id, $problem_id)
 {
     $letter = $this->ProblemLetter($contest_id, $problem_id);
     $letter = db_field_value('tester_tasks', 'letter', "`contest_id`={$contest_id} AND " . "`problem_id`={$problem_id}");
     $count = $this->GetProblemsCountAtContest($contest_id);
     if ($letter >= $count) {
         return;
     }
     $letter2 = $letter + 1;
     $id1 = db_field_value('tester_tasks', 'id', "`contest_id`={$contest_id} AND " . "`problem_id`={$problem_id}");
     $id2 = db_field_value('tester_tasks', 'id', "`contest_id`={$contest_id} AND " . "`letter`={$letter2}");
     db_swap_values('tester_tasks', $id1, $id2, 'letter', $idfield = 'id');
 }
Ejemplo n.º 2
0
 function db_move_down($table, $id, $clause = '', $idfield = 'id', $orderfield = 'order')
 {
     $order = db_field_value($table, $orderfield, "`{$idfield}`={$id}");
     if ($order == '') {
         return false;
     }
     $min = db_min($table, 'order', "`{$orderfield}`>{$order}" . (trim($clause) != '' ? ' AND ' . $clause : ''));
     if ($min == '') {
         return false;
     }
     $next = db_field_value($table, $idfield, "`{$orderfield}`={$min}" . (trim($clause) != '' ? ' AND ' . $clause : ''));
     if ($next == '') {
         return false;
     }
     return db_swap_values($table, $id, $next, $orderfield, $idfield);
 }