Changeset 816 for trunk/includes/Update.php
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/Update.php
r815 r816 11 11 function __construct() 12 12 { 13 14 15 13 $this->Revision = 0; 14 $this->Trace = array(); 15 $this->VersionTable = 'DbVersion'; 16 16 } 17 17 18 18 function GetDbVersion() 19 19 { 20 21 20 $DbResult = $this->Database->select('DbVersion', '*', 'Id=1'); 21 $Version = $DbResult->fetch_assoc(); 22 22 return($Version['Revision']); 23 23 } … … 25 25 function IsInstalled() 26 26 { 27 27 $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"'); 28 28 return($DbResult->num_rows > 0); 29 29 } … … 31 31 function IsUpToDate() 32 32 { 33 33 return($this->Revision <= $this->GetDbVersion()); 34 34 } 35 35 36 36 function Update() 37 37 { 38 39 40 38 $DbRevision = $this->GetDbVersion(); 39 $Output = 'Počáteční revize databáze: '.$DbRevision.'<br/>'; 40 while($this->Revision > $DbRevision) 41 41 { 42 43 44 45 46 47 48 49 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); 50 50 } 51 51 52 52 function Install() 53 53 { 54 55 56 54 $InstallMethod = $this->InstallMethod; 55 $InstallMethod($this); 56 $this->Update(); 57 57 } 58 58 … … 64 64 function Execute($Query) 65 65 { 66 67 68 66 echo($Query.'<br/>'); 67 flush(); 68 return($this->Database->query($Query)); 69 69 } 70 70 }
Note:
See TracChangeset
for help on using the changeset viewer.