Changeset 37 for trunk


Ignore:
Timestamp:
Sep 10, 2020, 10:25:07 PM (4 years ago)
Author:
chronos
Message:
  • Fixed: Update runner team if it was later changed.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r36 r37  
    159159
    160160    $Runners = array();
    161     $DbResult = $this->Database->query('SELECT Runner.Id, Runner.ChipNumber, '.
     161    $DbResult = $this->Database->query('SELECT Runner.Id, Runner.ChipNumber, Runner.Team, '.
    162162      '(SELECT RunnerStat.Distance FROM RunnerStat WHERE (RunnerStat.Runner = Runner.Id) ORDER BY RunnerStat.Distance DESC LIMIT 1) AS Distance '.
    163163      'FROM Runner WHERE Year='.$Year);
     
    203203                'IsFamily' => 0,
    204204              ));
    205               $Teams[$Item['TeamId']] = array('Id' => $TeamId, 'Distance' => -1);
     205              $Teams[$Item['TeamId']] = array('Id' => $TeamId, 'Distance' => -1, 'Team' => $Item['TeamId']);
    206206              $NextTeamId++;
    207207            } else
     
    224224          $Runners[$Item['ChipNumber']] = array('Id' => $RunnerId, 'Distance' => -1);
    225225          $NextRunnerId++;
    226         } else
     226        } else {
    227227          $RunnerId = $Runners[$Item['ChipNumber']]['Id'];
     228
     229          // Update runner team if it was changed
     230          if ($Item['TeamId'] != $Runners[$Item['ChipNumber']]['Team'] and array_key_exists($Item['TeamId'], $Teams))
     231          {
     232            $Runners[$Item['ChipNumber']]['Team'] = $Item['TeamId'];
     233            $Queries[] = $this->Database->GetUpdate('Runner', 'Id='.$RunnerId, array('Team' => $Item['TeamId']));
     234          }
     235        }
    228236
    229237        if ($Runners[$Item['ChipNumber']]['Distance'] < $Item['OverallDistance'])
Note: See TracChangeset for help on using the changeset viewer.