Пример #1
0
function UpdatePreOpen($TournamentID)
{
    // checks if the structure of the database is consistent
    //	CheckDbStructure();
    $DbVersion = GetParameter('DBUpdate');
    $rs = safe_r_SQL("SELECT ToDbVersion, ToType, ToNumSession FROM Tournament WHERE ToId='{$TournamentID}'");
    $row = safe_fetch($rs);
    $version = $row->ToDbVersion;
    if ($version < '2010-11-26 15:50:00') {
        updateEnTimeStamp_20101126($TournamentID);
        to_save_version($TournamentID, '2010-11-26 15:50:00');
    }
    if ($version < '2010-12-11 20:30:00') {
        recalculateIndividuals_20101211($TournamentID);
        to_save_version($TournamentID, '2010-12-11 20:30:00');
    }
    if ($version < '2011-02-16 15:42:00') {
        // metto a posto il numero max di persone nei team
        calcMaxTeamPerson_20110216($TournamentID);
        // ricalcolo le rank a squadra
        recalculateTeamRanking_20110216($TournamentID);
        to_save_version($TournamentID, '2011-02-16 15:42:00');
    }
    if ($version < '2011-03-09 14:38:00') {
        initTourGoldsXNineChars_20110309($TournamentID);
        to_save_version($TournamentID, '2011-03-09 14:38:00');
    }
    if ($version < '2011-04-15 15:55:00') {
        RecalcFinRank_20110415($TournamentID);
        to_save_version($TournamentID, '2011-04-15 15:55:00');
    }
    if ($version < '2012-01-11 10:20:00') {
        Update3DIta_20120111($TournamentID);
        to_save_version($TournamentID, '2012-01-11 10:20:00');
    }
    if ($version < '2012-01-24 15:16:00') {
        $q = insertIntoGridForF2F_21($TournamentID);
        $rs2 = safe_w_sql($q, false, array(1062));
        to_save_version($TournamentID, '2012-01-24 15:16:00');
    }
    if ($version < '2012-05-18 07:10:00') {
        safe_w_sql("update Divisions set DivWaDivision=DivId, DivRecDivision=DivId where DivWaDivision='' or DivRecDivision=''");
        safe_w_sql("update Classes set ClWaClass=ClId, ClRecClass=ClId where ClWaClass='' or ClRecClass=''");
        safe_w_sql("update Events set EvWaCategory=EvCode, EvRecCategory=EvCode where EvWaCategory='' or EvRecCategory=''");
        to_save_version($TournamentID, '2012-05-18 07:10:00');
    }
    if ($version < '2013-12-19 12:30:00') {
        // Updating DistanceInformation
        require_once 'Modules/Sets/lib.php';
        require_once 'Tournament/Fun_ManSessions.inc.php';
        $Distances = getDistanceArrays($row->ToType);
        $q = safe_r_sql("select SesAth4Target, SesOrder from Session where SesTournament={$TournamentID}");
        while ($r = safe_fetch($q)) {
            CreateDistanceInformation($TournamentID, $Distances, 0, $r->SesAth4Target, $r->SesOrder);
        }
        to_save_version($TournamentID, '2013-12-19 12:30:00');
    }
    if ($version < '2014-03-22 14:00:00') {
        UpdateWinLose_20140322($TournamentID);
        to_save_version($TournamentID, '2014-03-22 14:00:00');
    }
    if ($version < '2014-04-01 00:00:00') {
        UpdateItaRules_20140401($TournamentID);
        to_save_version($TournamentID, '2014-04-01 00:00:00');
    }
    if ($version < '2014-05-23 16:00:00') {
        safe_w_sql("update Scheduler\n\t\t\tleft join Session on SchTournament=SesTournament and SchSesOrder=SesOrder and SchSesType=SesType\n\t\t\tset SchDay=date(SchDateStart), SchStart=time(SchDateStart), SchDuration=TIMESTAMPDIFF(MINUTE, SchDateStart, SchDateEnd), SchText=SchDescr, SchTitle=SesName\n\t\t\twhere SchTournament={$TournamentID}");
        $q = safe_r_sql("select * from Scheduler where SchTournament={$TournamentID} and SchDay>0 and SchStart>0 order by SchDay, SchStart, SchOrder desc");
        $oldKeys = array();
        while ($r = safe_fetch($q)) {
            $good = true;
            $key = $r->SchDay . '|' . $r->SchStart;
            while (in_array($key, $oldKeys)) {
                $key++;
                $good = false;
            }
            $oldKeys[] = $key;
            if (!$good) {
                $SQL = "update Scheduler set SchStart='" . substr($key, -8) . "' where SchDay='{$r->SchDay}' and SchStart='{$r->SchStart}' and SchDuration='{$r->SchDuration}' and SchSesOrder={$r->SchSesOrder} and SchOrder={$r->SchOrder} and SchSesType='{$r->SchSesType}' limit 1";
                safe_w_sql($SQL);
            }
        }
        to_save_version($TournamentID, '2014-04-01 00:00:00');
    }
    to_save_version($TournamentID, $DbVersion);
}
Пример #2
0
    // aggiungo la colonna x salvare se quella rank ha dei pari oppure no.
    $MySql = "ALTER TABLE `Eliminations` ADD `ElSO` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `ElRank`; ";
    safe_w_SQL($MySql, false, array(1060));
    db_save_version('2010-11-29 11:03:00');
}
if ($version < '2010-12-03 16:40:00') {
    // aggiungo la colonna x le frecce di spareggio delle eliminatorie
    $MySql = "ALTER TABLE `Eliminations` ADD `ElTiebreak` VARCHAR( 8 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `ElArrowString` ; ";
    safe_w_SQL($MySql, false, array(1060));
    db_save_version('2010-12-03 16:40:00');
}
if ($version < '2010-12-11 20:30:00') {
    $MySql = "ALTER TABLE `Individuals` CHANGE `IndSO` `IndSO` SMALLINT NOT NULL DEFAULT '0'";
    safe_w_SQL($MySql);
    $MySql = "ALTER TABLE `Eliminations` CHANGE `ElSO` `ElSO` SMALLINT NOT NULL DEFAULT '0'";
    safe_w_SQL($MySql);
    $MySql = "ALTER TABLE `HhtData` ADD `HdRealTargetNo` VARCHAR( 3 ) NOT NULL ,\n\t\tADD `HdLetter` VARCHAR( 1 ) NOT NULL";
    safe_w_SQL($MySql, false, array(1060));
    $MySql = "SELECT ToId From Tournament";
    $rs = safe_r_SQL($MySql);
    while ($myRow = safe_fetch($rs)) {
        recalculateIndividuals_20101211($myRow->ToId);
    }
    //Riporto i QuRank e le freccie di Shootoff dalla tabella qualifications
    $MySql = "UPDATE Entries\n\t\tINNER JOIN Qualifications On QuId=EnId\n\t\tINNER JOIN EventClass ON EcTeamEvent=0 AND EcTournament=EnTournament AND EcClass=EnClass AND EcDivision=EnDivision\n\t\tINNER JOIN Individuals ON IndId=EnId AND IndEvent=EcCode AND IndTournament=EnTournament\n\t\tSET IndRank=QuRank, IndTieBreak=QuTieBreak\n\t\tWHERE QuRank!=0 AND (QuRank!=IndRank OR QutieBreak!=IndTieBreak)";
    safe_w_SQL($MySql);
    //riporto la posizione dalla tabella finali... mi serve solo per partecipazioni ad eventi multi pli sennò bastava query sopra
    $MySql = "UPDATE Individuals\n\t\tINNER JOIN Finals ON IndId=FinAthlete AND IndEvent=FinEvent AND IndTournament=FinTournament\n\t\tINNER JOIN Events ON EvCode=FinEvent AND EvTeamEvent=0 AND EvTournament=FinTournament\n\t\tINNER JOIN Grids ON GrMatchNo=FinMatchNo AND GrPhase=IF(EvFinalFirstPhase=24,32,EvFinalFirstPhase)\n\t\tSET IndRank=GrPosition\n\t\tWHERE FinAthlete!=0 AND (EvElim1=0 AND EvElim2=0)";
    safe_w_SQL($MySql);
    db_save_version('2010-12-11 20:30:00');
}