Ignore:
Timestamp:
Feb 22, 2015, 11:20:50 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Tabs converted to spaces.
  • Modified: Remove spaces from end of lines.
  • Added: Code format script.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/Update.php

    r815 r816  
    1111  function __construct()
    1212  {
    13           $this->Revision = 0;
    14           $this->Trace = array();
    15           $this->VersionTable = 'DbVersion';
     13    $this->Revision = 0;
     14    $this->Trace = array();
     15    $this->VersionTable = 'DbVersion';
    1616  }
    1717
    1818  function GetDbVersion()
    1919  {
    20           $DbResult = $this->Database->select('DbVersion', '*', 'Id=1');
    21           $Version = $DbResult->fetch_assoc();
     20    $DbResult = $this->Database->select('DbVersion', '*', 'Id=1');
     21    $Version = $DbResult->fetch_assoc();
    2222    return($Version['Revision']);
    2323  }
     
    2525  function IsInstalled()
    2626  {
    27           $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"');
     27    $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"');
    2828    return($DbResult->num_rows > 0);
    2929  }
     
    3131  function IsUpToDate()
    3232  {
    33           return($this->Revision <= $this->GetDbVersion());
     33    return($this->Revision <= $this->GetDbVersion());
    3434  }
    3535
    3636  function Update()
    3737  {
    38           $DbRevision = $this->GetDbVersion();
    39         $Output = 'Počáteční revize databáze: '.$DbRevision.'<br/>';
    40           while($this->Revision > $DbRevision)
     38    $DbRevision = $this->GetDbVersion();
     39    $Output = 'Počáteční revize databáze: '.$DbRevision.'<br/>';
     40    while($this->Revision > $DbRevision)
    4141    {
    42             $TraceItem = $this->Trace[$DbRevision];
    43             $Output .= 'Aktualizace na verzi: '.$TraceItem['Revision'].'<br/>';
    44             $RevUpdate = $TraceItem['Function'];
    45             $RevUpdate($this);
    46             $DbRevision = $TraceItem['Revision'];
    47             $this->Database->query('UPDATE `DbVersion` SET `Revision`= '.$TraceItem['Revision'].' WHERE `Id`=1');
    48           }
    49           return($Output);
     42      $TraceItem = $this->Trace[$DbRevision];
     43      $Output .= 'Aktualizace na verzi: '.$TraceItem['Revision'].'<br/>';
     44      $RevUpdate = $TraceItem['Function'];
     45      $RevUpdate($this);
     46      $DbRevision = $TraceItem['Revision'];
     47      $this->Database->query('UPDATE `DbVersion` SET `Revision`= '.$TraceItem['Revision'].' WHERE `Id`=1');
     48    }
     49    return($Output);
    5050  }
    5151
    5252  function Install()
    5353  {
    54         $InstallMethod = $this->InstallMethod;
    55         $InstallMethod($this);
    56         $this->Update();
     54    $InstallMethod = $this->InstallMethod;
     55    $InstallMethod($this);
     56    $this->Update();
    5757  }
    5858
     
    6464  function Execute($Query)
    6565  {
    66           echo($Query.'<br/>');
    67           flush();
    68           return($this->Database->query($Query));
     66    echo($Query.'<br/>');
     67    flush();
     68    return($this->Database->query($Query));
    6969  }
    7070}
Note: See TracChangeset for help on using the changeset viewer.