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