Changeset 888 for trunk/Packages/Common/Update.php
- Timestamp:
- Dec 27, 2022, 7:50:23 PM (23 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Update.php
r880 r888 3 3 class UpdateManager 4 4 { 5 var $Revision; 6 var $Trace; 7 var $VersionTable; 8 /* @var Database */ 9 var $Database; 10 var $InstallMethod; 5 public int $Revision; 6 public array $Trace; 7 public string $VersionTable; 8 public Database $Database; 9 public string $InstallMethod; 11 10 12 11 function __construct() … … 19 18 } 20 19 21 function GetDbVersion() 20 function GetDbVersion(): ?int 22 21 { 23 22 $DbResult = $this->Database->select($this->VersionTable, '*', 'Id=1'); … … 26 25 } 27 26 28 function IsInstalled() 27 function IsInstalled(): bool 29 28 { 30 29 $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"'); … … 32 31 } 33 32 34 function IsUpToDate() 33 function IsUpToDate(): bool 35 34 { 36 35 return $this->Revision <= $this->GetDbVersion(); 37 36 } 38 37 39 function Upgrade() 38 function Upgrade(): string 40 39 { 41 40 $DbRevision = $this->GetDbVersion(); … … 43 42 while ($this->Revision > $DbRevision) 44 43 { 44 if (!array_key_exists($DbRevision, $this->Trace)) 45 die('Missing upgrade trace for revision '.$DbRevision); 45 46 $TraceItem = $this->Trace[$DbRevision]; 46 47 $Output .= 'Aktualizace na verzi '.$TraceItem['Revision'].':<br/>'; … … 57 58 } 58 59 59 function Install() 60 function Install(): void 60 61 { 61 62 $InstallMethod = $this->InstallMethod; 62 63 $InstallMethod($this); 63 $this->Update();64 64 } 65 65 66 function Uninstall() 66 function Uninstall(): void 67 67 { 68 69 68 } 70 69 71 function InsertSampleData() 70 function InsertSampleData(): void 72 71 { 73 72 $InstallMethod = $this->InsertSampleDataMethod; … … 75 74 } 76 75 77 function Execute( $Query)76 function Execute(string $Query): DatabaseResult 78 77 { 79 78 echo($Query.';<br/>');
Note:
See TracChangeset
for help on using the changeset viewer.