Changeset 890 for trunk/Packages/Common/AppModule.php
- Timestamp:
- Dec 29, 2020, 11:11:12 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/AppModule.php
r889 r890 90 90 $this->Stop(); 91 91 $this->Installed = false; 92 $List = array(); 92 $List = array(); 93 93 $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Installed)); 94 94 $this->Manager->Perform($List, array(ModuleAction::Uninstall), array(ModuleCondition::Installed)); … … 187 187 function InstallModel(ModelDesc $ModelDesc) 188 188 { 189 $Query = 'CREATE TABLE IF NOT EXISTS `'.$ModelDesc->Name.'` ('."\n";190 $Query = ' `'.$ModelDesc->PrimaryKey.'` int(11) NOT NULL AUTO_INCREMENT,'."\n";189 $Query = "CREATE TABLE IF NOT EXISTS `".$ModelDesc->Name."` (\n"; 190 $Query .= ' `'.$ModelDesc->PrimaryKey.'` int(11) NOT NULL AUTO_INCREMENT,'."\n"; 191 191 foreach ($ModelDesc->Columns as $Column) 192 192 { … … 198 198 else if ($Column->Type == ModelColumnType::DateTime) $Query .= 'datetime'; 199 199 else if ($Column->Type == ModelColumnType::Reference) $Query .= 'int(11)'; 200 else if ($Column->Type == ModelColumnType::Boolean) $Query .= 'tinyint(1)'; 201 else if ($Column->Type == ModelColumnType::Date) $Query .= 'date'; 202 else if ($Column->Type == ModelColumnType::Enum) 203 { 204 $Query .= 'enum("'.implode('", "', $Column->States).'")'; 205 } 200 206 201 207 if ($Column->Nullable) $Query .= ''; … … 212 218 $Query .= ",\n"; 213 219 } 214 $Query .= ' PRIMARY KEY (`'.$ModelDesc->PrimaryKey.'`) ,';220 $Query .= ' PRIMARY KEY (`'.$ModelDesc->PrimaryKey.'`)'; 215 221 foreach ($ModelDesc->Columns as $Column) 216 222 { 217 223 if ($Column->Type == ModelColumnType::Reference) 218 $Query .= ' KEY `'.$Column->Name.'` (`'.$Column->Name.'`)'."\n";224 $Query .= ','."\n".' KEY `'.$Column->Name.'` (`'.$Column->Name.'`)'; 219 225 else if ($Column->Unique) 220 $Query .= ' UNIQUE KEY `'.$Column->Name.'` (`'.$Column->Name.'`)'."\n"; 221 } 222 223 $Query .= ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;"; 226 $Query .= ','."\n".' UNIQUE KEY `'.$Column->Name.'` (`'.$Column->Name.'`)'; 227 } 228 $Query .= "\n"; 229 230 if ($ModelDesc->Memory) $Engine = 'MEMORY'; 231 else $Engine = 'InnoDB'; 232 $Query .= ') ENGINE='.$Engine.' DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'; 224 233 $I = 1; 225 234 foreach ($ModelDesc->Columns as $Column) … … 229 238 "ADD CONSTRAINT `".$ModelDesc->Name."_ibfk_".$I."` FOREIGN KEY (`".$Column->Name."`) REFERENCES `".$Column->RefTable."` (`Id`);"; 230 239 } 240 echo($Query); 231 241 $this->Database->query($Query); 232 242 } … … 234 244 function UninstallModel(ModelDesc $ModelDesc) 235 245 { 236 $this->Database->query('DROP TABLE `'.$ModelDesc->Name.'`');246 $this->Database->query('DROP TABLE IF EXISTS `'.$ModelDesc->Name.'`'); 237 247 } 238 248 } … … 289 299 $DepModule = $this->Modules[$Dependency]; 290 300 if (in_array(ModuleCondition::All, $Conditions) or 291 ($ Module->Running and in_array(ModuleCondition::Running, $Conditions)) or292 (!$ Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or293 ($ Module->Enabled and in_array(ModuleCondition::Enabled, $Conditions)) or294 (!$ Module->Enabled and in_array(ModuleCondition::NotEnabled, $Conditions)) or295 ($ Module->Installed and in_array(ModuleCondition::Installed, $Conditions)) or296 (!$ Module->Installed and in_array(ModuleCondition::NotInstalled, $Conditions)))301 ($DepModule->Running and in_array(ModuleCondition::Running, $Conditions)) or 302 (!$DepModule->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or 303 ($DepModule->Enabled and in_array(ModuleCondition::Enabled, $Conditions)) or 304 (!$DepModule->Enabled and in_array(ModuleCondition::NotEnabled, $Conditions)) or 305 ($DepModule->Installed and in_array(ModuleCondition::Installed, $Conditions)) or 306 (!$DepModule->Installed and in_array(ModuleCondition::NotInstalled, $Conditions))) 297 307 { 298 308 array_push($List, $DepModule); … … 308 318 if (in_array($Module->Name, $RefModule->Dependencies) and 309 319 (in_array(ModuleCondition::All, $Conditions) or 310 ($ Module->Running and in_array(ModuleCondition::Running, $Conditions)) or311 (!$ Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or312 ($ Module->Enabled and in_array(ModuleCondition::Enabled, $Conditions)) or313 (!$ Module->Enabled and in_array(ModuleCondition::NotEnabled, $Conditions)) or314 ($ Module->Installed and in_array(ModuleCondition::Installed, $Conditions)) or315 (!$ Module->Installed and in_array(ModuleCondition::NotInstalled, $Conditions))))320 ($RefModule->Running and in_array(ModuleCondition::Running, $Conditions)) or 321 (!$RefModule->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or 322 ($RefModule->Enabled and in_array(ModuleCondition::Enabled, $Conditions)) or 323 (!$RefModule->Enabled and in_array(ModuleCondition::NotEnabled, $Conditions)) or 324 ($RefModule->Installed and in_array(ModuleCondition::Installed, $Conditions)) or 325 (!$RefModule->Installed and in_array(ModuleCondition::NotInstalled, $Conditions)))) 316 326 { 317 327 array_push($List, $RefModule);
Note:
See TracChangeset
for help on using the changeset viewer.