Changeset 9 for branches/2/mangos_import.php
- Timestamp:
- May 9, 2008, 2:04:07 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2/mangos_import.php
r8 r9 6 6 { 7 7 $Output = ''; 8 $this->Database-> delete('Text', '`Text`.`TranslationGroup`=(SELECT `TextGroup`.`Id` FROM `TextGroup` WHERE `TextGroup`.`Language`=1)');8 $this->Database->query('DELETE FROM `Text` JOIN `TextGroup` ON `TextGroup`.`Language`=1 AND `TextGroup`.`Id` = `Text`.`TranslationGroup`'); 9 9 echo($this->Database->error); 10 $this->Database->delete('T ranslationGroup', '`Language`=1');10 $this->Database->delete('TextGroup', '`Language`=1'); 11 11 echo($this->Database->error); 12 12 … … 47 47 function ImportOldSystem() 48 48 { 49 $Output = ''; 50 51 // Import users 52 $this->Database->query('TRUNCATE TABLE `User`'); 53 $DbResult = $this->Database->query('SELECT * FROM `quests`.`user`'); 54 while($User = $DbResult->fetch_array()) 55 { 56 $Language = $User['Language'] + 1; 57 if($Language == 1) $Language = 2; 58 $Role = 2; 59 if($User['gm'] == 1) $Role = 3; 60 if($User['gm'] == 2) $Role = 4; 61 $this->Database->insert('User', array('Name' => $User['user'], 'Password' => $User['pass'], 'Email' => $User['Email'], 'TranslationLanguage' => $Language, 'LastLoginTime' => $User['LastLogin'], 'LastIpAddress' => $User['LastIP'], 'Role' => $Role, 'Id' => $User['ID'])); 62 } 63 $this->Database->insert('User', array('Name' => 'Anonym', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1)); 64 $this->Database->insert('User', array('Name' => 'MaNGOS', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1)); 65 $this->Database->insert('User', array('Name' => 'WoWEmu', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1)); 66 $UnknownUserId = $this->Database->insert_id; 67 $Output .= 'Uživatelé převedeni<br>'; 68 69 // Import texts 70 $this->Database->query('CREATE TABLE Transition (OldIndex INT, NewIndex INT, INDEX OldIndex ) ENGINE=MEMORY'); 71 //$this->Database->query('TRUNCATE TABLE `User`'); 72 $DbResult = $this->Database->query('SELECT * FROM `quests`.`quests`'); 73 while($Quest = $DbResult->fetch_array()) 74 { 75 if($Quest['Language'] > 0) 76 { 77 if($Quest['User'] == 0) $Quest['User'] = $UnknownUserId; 78 if($Quest['Take'] > 0) 79 { 80 $DbResult2 = $this->Database->select('Transition', 'NewIndex', 'OldIndex='.$Quest['Take']); 81 $DbRow2 = $DbResult2->fetch_array(); 82 $Take = $DbRow2['NewIndex']; 83 } else $Take = 0; 84 85 $this->Database->insert('TextGroup', array('Index' => $Quest['entry'], 'Group' => 1, 'Time' => 'NOW()', 'Language' => $Quest['Language'] + 1, 'OldSystem' => 1, 'Complete' => $Quest['complete'], 'OriginalText' => $Take)); 86 //echo($this->Database->LastQuery); 87 $TextGroupId = $this->Database->insert_id; 88 $this->Database->insert('Transition', array('OldIndex' => $Quest['ID'], 'NewIndex' => $TextGroupId)); 89 if($Quest['Title'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 1, 'Text' => $Quest['Title'])); 90 if($Quest['Details'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 2, 'Text' => $Quest['Details'])); 91 if($Quest['Objectives'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 3, 'Text' => $Quest['Objectives'])); 92 if($Quest['OfferRewardText'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 4, 'Text' => $Quest['OfferRewardText'])); 93 if($Quest['RequestItemsText'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 5, 'Text' => $Quest['RequestItemsText'])); 94 if($Quest['EndText'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 6, 'Text' => $Quest['EndText'])); 95 if($Quest['ObjectiveText1'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 7, 'Text' => $Quest['ObjectiveText1'])); 96 if($Quest['ObjectiveText2'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 8, 'Text' => $Quest['ObjectiveText2'])); 97 if($Quest['ObjectiveText3'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 9, 'Text' => $Quest['ObjectiveText3'])); 98 if($Quest['ObjectiveText4'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 10, 'Text' => $Quest['ObjectiveText4'])); 99 } 100 } 101 $this->Database->query('DROP TABLE Transition'); 102 $Output .= 'Questy převedeny<br>'; 103 return($Output); 49 104 } 50 105 }
Note:
See TracChangeset
for help on using the changeset viewer.