Changeset 49 for trunk/fill_database.php
- Timestamp:
- Jan 30, 2009, 10:33:08 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:ignore
set to
SqlTranslate.zip
-
Property svn:ignore
set to
-
trunk/fill_database.php
r43 r49 1 1 <?php 2 2 3 3 include('includes/global.php'); 4 4 5 echo 'Načítání questů z databáze: '; 5 echo('Načítání textů z databáze MaNGOSu: '); 6 echo('<div style="font-size: xx-small;">'); 6 7 7 $sql = "SELECT * FROM mangos.quest_template as mangos_quests 8 WHERE NOT EXISTS (SELECT * FROM quests.quests WHERE quests.quests.entry=mangos_quests.entry)"; 8 foreach($TranslationTree as $Group) 9 { 10 if(($Group['MangosTable'] != '') and ($Group['TablePrefix'] != '')) 11 { 12 echo('<br />'.$Group['Name'].'<br />'); 13 $Columns = '`'.$Config['Database']['DatabaseMangos'].'`.`'.$Group['MangosTable'].'`.`'.$Group['MangosTableIndex'].'`'; 14 foreach($Group['Items'] as $GroupItem) 15 $Columns .= ', `'.$Config['Database']['DatabaseMangos'].'`.`'.$Group['MangosTable'].'`.`'.$GroupItem['MangosColumn'].'` AS `'.$GroupItem['Column'].'`'; 16 $Query = 'SELECT '.$Columns.' FROM `'.$Config['Database']['DatabaseMangos'].'`.`'.$Group['MangosTable'].'`'; 17 echo($Query.'<br />'); 18 $Count = 0; 19 $NewCount = 0; 20 $DbResult = $Database->SQLCommand($Query); 21 while($DbRow = mysql_fetch_assoc($DbResult)) 22 { 23 //echo('SELECT ID FROM '.$Group['TablePrefix'].' WHERE entry='.$DbRow[$Group['MangosTableIndex']].' AND Language=0'."<br>"); 24 $DbResult2 = $Database->SQLCommand('SELECT ID FROM '.$Group['TablePrefix'].' WHERE entry='.$DbRow[$Group['MangosTableIndex']].' AND Language=0'); 25 if(isset($DbResult2) and (mysql_num_rows($DbResult2) > 0)) 26 { 27 $DbRow2 = mysql_fetch_assoc($DbResult2); 28 //echo($DbRow2['ID']); 29 $ColumnsValues = ''; 30 foreach($Group['Items'] as $GroupItem) 31 { 32 $ColumnsValues .= ', `'.$GroupItem['Column'].'`="'.addslashes($DbRow[$GroupItem['MangosColumn']]).'"'; 33 } 34 $ColumnsValues = substr($ColumnsValues, 2); 35 echo('. '); //'UPDATE `'.$Group['TablePrefix'].'` SET '.$ColumnsValues.' WHERE ID='.$DbRow2['ID']."<br>"); 36 //print_r($DbRow2); 37 $Database->SQLCommand('UPDATE `'.$Group['TablePrefix'].'` SET '.$ColumnsValues.' WHERE ID='.$DbRow2['ID']); 38 } else 39 { 40 $Columns = 'entry, language'; 41 $Values = $DbRow[$Group['MangosTableIndex']].', 0'; 42 foreach($Group['Items'] as $GroupItem) 43 { 44 $Columns .= ', `'.$GroupItem['Column'].'`'; 45 $Values .= ', "'.addslashes($DbRow[$GroupItem['MangosColumn']]).'"'; 46 } 47 //$Columns = substr($Columns, 2); 48 //$Values = substr($Values, 2); 49 $Database->SQLCommand('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 50 echo('# '); 51 //echo('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'."<br>"); 52 $NewCount++; 53 } 54 $Count++; 55 } 56 echo('<br />Celkem: '.$Count.' Nových: '.$NewCount.'<br />'); 57 } 58 } 59 echo('Dokončeno.</div>'); 9 60 10 $ID = $Database->SQLCommand($sql); 11 while ($Line = mysql_fetch_array($ID)) { 61 WriteLog('Plnění databáze', 4); 12 62 13 $sql = " 14 INSERT INTO `quests` ( `ID` , `entry` , `Title` , `Details` , `Objectives` , 15 `OfferRewardText` , `RequestItemsText` , `EndText` , `ObjectiveText1` , `ObjectiveText2` , 16 `ObjectiveText3` , `ObjectiveText4` , `Language`) 17 VALUES (NULL , '".mysql_escape_string($Line['entry'])."', '".mysql_escape_string($Line['Title'])."', '".mysql_escape_string($Line['Details'])."', 18 '".mysql_escape_string($Line['Objectives'])."', '".mysql_escape_string($Line['OfferRewardText'])."', '".mysql_escape_string($Line['RequestItemsText'])."', '".mysql_escape_string($Line['EndText'])."', 19 '".mysql_escape_string($Line['ObjectiveText1'])."', '".mysql_escape_string($Line['ObjectiveText2'])."', '".mysql_escape_string($Line['ObjectiveText3'])."', '".mysql_escape_string($Line['ObjectiveText4'])."', '0')"; 20 // echo $sql; 21 $Database->SQLCommand($sql); 22 } 23 echo 'HOTOVO'; 24 25 WriteLog('Plnění databáze', 4); 26 27 28 ShowFooter(); 63 ShowFooter(); 64 29 65 ?>
Note:
See TracChangeset
for help on using the changeset viewer.