Changeset 401 for branches/Modular/Common/Module.php
- Timestamp:
- Mar 30, 2012, 2:02:51 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Modular/Common/Module.php
r398 r401 120 120 { 121 121 //DebugLog('Installing modular system core...'); 122 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemVersion` ( 123 `Id` int(11) NOT NULL AUTO_INCREMENT, 124 `Version` varchar(255) COLLATE utf8_czech_ci NOT NULL, 125 `Description` datetime NOT NULL, 126 PRIMARY KEY (`Id`) 127 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;'); 122 128 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModule` ( 123 129 `Id` int(11) NOT NULL AUTO_INCREMENT, … … 140 146 UNIQUE (`Module` , `DependencyModule`) 141 147 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;'); 142 $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)');143 $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD FOREIGN KEY ( `DependencyModule` ) REFERENCES `SystemModule` (`Id`)');148 $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD CONSTRAINT `SystemModuleDependency_ibfk_1` FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)'); 149 $this->Database->query('ALTER TABLE `SystemModuleDependency` ADD CONSTRAINT `SystemModuleDependency_ibfk_2` FOREIGN KEY ( `DependencyModule` ) REFERENCES `SystemModule` (`Id`)'); 144 150 145 151 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModel` ( … … 150 156 PRIMARY KEY (`Id`) 151 157 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;'); 152 $this->Database->query('ALTER TABLE `SystemModel` ADD FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)');158 $this->Database->query('ALTER TABLE `SystemModel` ADD CONSTRAINT `SystemModel_ibfk_1` FOREIGN KEY ( `Module` ) REFERENCES `SystemModule` (`Id`)'); 153 159 154 160 $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemModelProperty` ( … … 160 166 PRIMARY KEY (`Id`) 161 167 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1;'); 162 $this->Database->query('ALTER TABLE `SystemModelProperty` ADD FOREIGN KEY ( `Model` ) REFERENCES `SystemModel` (`Id`)');168 $this->Database->query('ALTER TABLE `SystemModelProperty` ADD CONSTRAINT `SystemModelProperty_ibfk_1` FOREIGN KEY ( `Model` ) REFERENCES `SystemModel` (`Id`)'); 163 169 164 170 $this->ReloadList(); … … 178 184 179 185 // Delete tables with reverse order 186 $this->Database->query('ALTER TABLE `SystemModelProperty` DROP FOREIGN KEY `SystemModelProperty_ibfk_1`'); 180 187 $this->Database->query('DROP TABLE IF EXISTS `SystemModelProperty`'); 188 $this->Database->query('ALTER TABLE `SystemModel` DROP FOREIGN KEY `SystemModel_ibfk_1`'); 181 189 $this->Database->query('DROP TABLE IF EXISTS `SystemModel`'); 190 $this->Database->query('ALTER TABLE `SystemModuleDependency` DROP FOREIGN KEY `SystemModuleDependency_ibfk_1`'); 191 $this->Database->query('ALTER TABLE `SystemModuleDependency` DROP FOREIGN KEY `SystemModuleDependency_ibfk_2`'); 182 192 $this->Database->query('DROP TABLE IF EXISTS `SystemModuleDependency`'); 183 193 $this->Database->query('DROP TABLE IF EXISTS `SystemModule`'); 194 $this->Database->query('DROP TABLE IF EXISTS `SystemVersion`'); 195 } 196 197 function IsInstalled() 198 { 199 $DbResult = $this->Database->query('SELECT table_name FROM information_schema.tables 200 WHERE table_schema = "'.$this->Database->Database.'" AND table_name = "SystemVersion";'); 201 if($DbResult->num_rows > 0) return(true); 202 else return(false); 184 203 } 185 204
Note:
See TracChangeset
for help on using the changeset viewer.