Ignore:
Timestamp:
Apr 14, 2015, 10:20:16 PM (9 years ago)
Author:
chronos
Message:
  • Removed: Spaces on end of line.
  • Modified: Tabs converted to spaces.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Setup/Update.php

    r725 r738  
    99  var $Database;
    1010  var $InstallMethod;
    11  
     11
    1212  function __construct()
    1313  {
    14           $this->Revision = 0;
    15           $this->Trace = array();
    16           $this->VersionTable = 'SystemVersion';
    17           $this->InstallMethod = 'FullInstall';
    18           $this->InsertSampleDataMethod = 'InsertSampleData';
     14    $this->Revision = 0;
     15    $this->Trace = array();
     16    $this->VersionTable = 'SystemVersion';
     17    $this->InstallMethod = 'FullInstall';
     18    $this->InsertSampleDataMethod = 'InsertSampleData';
    1919  }
    20  
     20
    2121  function GetDbVersion()
    2222  {
    23           $DbResult = $this->Database->select($this->VersionTable, '*', 'Id=1');
    24           $Version = $DbResult->fetch_assoc();   
     23    $DbResult = $this->Database->select($this->VersionTable, '*', 'Id=1');
     24    $Version = $DbResult->fetch_assoc();
    2525    return($Version['Revision']);
    2626  }
    27  
     27
    2828  function IsInstalled()
    29   {     
     29  {
    3030    debug_backtrace();
    31           $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"');
    32     return($DbResult->num_rows > 0);   
     31    $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"');
     32    return($DbResult->num_rows > 0);
    3333  }
    3434
    3535  function IsUpToDate()
    3636  {
    37           return($this->Revision <= $this->GetDbVersion());
     37    return($this->Revision <= $this->GetDbVersion());
    3838  }
    39  
     39
    4040  function Upgrade()
    4141  {
    42           $DbRevision = $this->GetDbVersion();
    43         $Output = 'Počáteční revize databáze: '.$DbRevision.'<br/>';
    44           while($this->Revision > $DbRevision)
     42    $DbRevision = $this->GetDbVersion();
     43    $Output = 'Počáteční revize databáze: '.$DbRevision.'<br/>';
     44    while($this->Revision > $DbRevision)
    4545    {
    46             $TraceItem = $this->Trace[$DbRevision];
    47             $Output .= 'Aktualizace na verzi '.$TraceItem['Revision'].':<br/>';
    48             // Show applied SQL queries immediatelly
    49             echo($Output);
    50             $Output = '';
    51             $RevUpdate = $TraceItem['Function'];
     46      $TraceItem = $this->Trace[$DbRevision];
     47      $Output .= 'Aktualizace na verzi '.$TraceItem['Revision'].':<br/>';
     48      // Show applied SQL queries immediatelly
     49      echo($Output);
     50      $Output = '';
     51      $RevUpdate = $TraceItem['Function'];
    5252      $RevUpdate($this);
    53             $DbRevision = $TraceItem['Revision'];
    54             $this->Database->query('UPDATE `'.$this->VersionTable.'` SET `Revision`= '.
    55                 $TraceItem['Revision'].' WHERE `Id`=1');
    56           }
    57           return($Output);       
     53      $DbRevision = $TraceItem['Revision'];
     54      $this->Database->query('UPDATE `'.$this->VersionTable.'` SET `Revision`= '.
     55        $TraceItem['Revision'].' WHERE `Id`=1');
     56    }
     57    return($Output);
    5858  }
    59  
     59
    6060  function Install()
    61   {     
    62         $InstallMethod = $this->InstallMethod;
    63         $InstallMethod($this);
    64         $this->Update();
     61  {
     62    $InstallMethod = $this->InstallMethod;
     63    $InstallMethod($this);
     64    $this->Update();
    6565  }
    66  
     66
    6767  function Uninstall()
    6868  {
    69    
     69
    7070  }
    71  
     71
    7272  function InsertSampleData()
    73   {     
    74         $InstallMethod = $this->InsertSampleDataMethod;
    75         $InstallMethod($this);
     73  {
     74    $InstallMethod = $this->InsertSampleDataMethod;
     75    $InstallMethod($this);
    7676  }
    77  
     77
    7878  function Execute($Query)
    7979  {
    80           echo($Query.';<br/>');
    81           flush();
    82           return($this->Database->query($Query));
     80    echo($Query.';<br/>');
     81    flush();
     82    return($this->Database->query($Query));
    8383  }
    8484}
Note: See TracChangeset for help on using the changeset viewer.