Changeset 216 for trunk/import/import_dbc.php
- Timestamp:
- Jun 24, 2009, 10:30:42 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/import/import_dbc.php
r214 r216 1 1 <?php 2 /* 3 DELETE FROM `gametips` WHERE ID > 266; 4 DELETE FROM `spell` WHERE ID > 43672; 5 UPDATE `gametips` SET VersionStart = 8606,VersionEnd = 8606; 6 UPDATE `spell` SET VersionStart = 8606,VersionEnd = 8606; 7 DELETE FROM `log` WHERE Type = 11; 8 */ 9 2 10 3 function ImportDBC() 11 12 function ImportDBC($import_version) 4 13 { 5 14 global $Database, $TranslationTree, $Config; 15 $BuildNumber = GetBuildNumber($import_version); 6 16 7 17 echo('Načítání textů z DBC souborů...'); … … 12 22 echo('<br />'.$Group['Name'].'<br />'); 13 23 $DBCFile = new DBCFile(); 14 $DBCFile->OpenFile('../source/'.$ Config['Web']['GameVersion'].'/dbc/'.$Group['DBCFileName'].'.dbc', $Group['DBCColumns']);24 $DBCFile->OpenFile('../source/'.$import_version.'/dbc/'.$Group['DBCFileName'].'.dbc', GetDBCColumns($import_version,$Group['DBCFileName'])); 15 25 $ItemCount = $DBCFile->GetRecordCount(); 16 26 $NewCount = 0; … … 18 28 for($i = 0; $i < $ItemCount; $i++) 19 29 { 30 foreach($Group['Items'] as $GroupItem) 31 { 32 $Value[$GroupItem['Column']] = addslashes($DBCFile->GetString($i, GetDBCColumnIndex($import_version,$Group['DBCFileName'],$GroupItem['Column']))); 33 } 34 35 $Columns = ''; 36 foreach($Group['Items'] as $GroupItem) 37 { 38 $Columns .= ', '.$GroupItem['Column'].' '; 39 } 40 $Columns = substr($Columns, 1); 41 20 42 $ItemId = $DBCFile->GetUint($i, 0); 21 $DbResult2 = $Database->SQLCommand('SELECT ID FROM '.$Group['TablePrefix'].' WHERE entry='.$ItemId.' AND Language=0');43 $DbResult2 = $Database->SQLCommand('SELECT VersionEnd, ID, entry, '.$Columns.' FROM '.$Group['TablePrefix'].' WHERE entry='.$ItemId.' AND Language=0 ORDER BY VersionStart DESC LIMIT 1'); 22 44 if(isset($DbResult2) and (mysql_num_rows($DbResult2) > 0)) 23 45 { 24 $DbRow2 = mysql_fetch_assoc($DbResult2); 25 //echo($DbRow2['ID']); 26 $ColumnsValues = ''; 27 foreach($Group['Items'] as $GroupItem) 28 { 29 $ColumnsValues .= ', `'.$GroupItem['Column'].'`="'.addslashes($DBCFile->GetString($i, $GroupItem['DBCColumnIndex'])).'"'; 30 } 31 $ColumnsValues = substr($ColumnsValues, 2); 32 echo('. '); //'UPDATE `'.$Group['TablePrefix'].'` SET '.$ColumnsValues.' WHERE ID='.$DbRow2['ID']."<br>"); 33 //print_r($DbRow2); 34 $Database->SQLCommand('UPDATE `'.$Group['TablePrefix'].'` SET '.$ColumnsValues.' WHERE ID='.$DbRow2['ID']); 46 // Update existed text 47 $DbRow2 = mysql_fetch_assoc($DbResult2); 48 if(HaveSameText($Group, $DbRow2, $Value)) 49 { 50 if ($DbRow2['VersionEnd'] <> $BuildNumber) { 51 $Database->SQLCommand('UPDATE `'.$Group['TablePrefix'].'` SET VersionEnd = "'.$BuildNumber.'" WHERE ID='.$DbRow2['ID']); 52 echo(', '); 53 } else 54 echo('. '); 55 } else 56 { 57 $Columns = 'entry, language, VersionStart, VersionEnd'; 58 $Values = $DbRow2['entry'].', 0, '.$BuildNumber.', '.$BuildNumber; 59 foreach($Group['Items'] as $GroupItem) 60 { 61 $Columns .= ', `'.$GroupItem['Column'].'`'; 62 $Values .= ', "'.$Value[$GroupItem['Column']].'"'; 63 } 64 $Database->SQLCommand('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 65 echo('# '); 66 $NewCount++; 67 WriteLog('Text <a href="form.php?group='.$Group['Id'].'&ID='.$DbRow2['ID'].'">'.$DbRow2['ID'].'</a> ('.$DbRow2['entry'].') ze skupiny '.$Group['Name'].' byl v nové verzi '.$import_version.' změněn.', 11); 68 } 69 35 70 } else 36 { 37 $Columns = 'entry, language';38 $Values = $ItemId.', 0';39 foreach($Group['Items'] as $GroupItem) 40 { 41 $Columns .= ', `'.$GroupItem['Column'].'`'; 42 $Values .= ', "'.addslashes($DBCFile->GetString($i, $GroupItem['DBCColumnIndex'])).'"';43 } 44 //$Columns = substr($Columns, 2); 45 //$Values = substr($Values, 2);46 $Database->SQLCommand('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')');47 echo('# ');48 //echo('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'."<br>");49 $NewCount++; 71 { 72 // Insert new text 73 $Columns = 'entry, language, VersionStart, VersionEnd'; 74 $Values = $ItemId.', 0, '.$BuildNumber.', '.$BuildNumber; 75 foreach($Group['Items'] as $GroupItem) 76 { 77 $Columns .= ', `'.$GroupItem['Column'].'`'; 78 $Values .= ', "'.$Value[$GroupItem['Column']].'"'; 79 } 80 $Database->SQLCommand('INSERT `'.$Group['TablePrefix'].'` ('.$Columns.') VALUES ('.$Values.')'); 81 echo('+ '); 82 $NewCount++; 83 WriteLog('Text <a href="form.php?group='.$Group['Id'].'&ID='.mysql_insert_id().'">'.$DbRow2['ID'].'</a> ('.$ItemId.') ze skupiny '.$Group['Name'].' byl v nové verzi '.$import_version.' přidán.', 11); 84 50 85 } 51 86 $Count++;
Note:
See TracChangeset
for help on using the changeset viewer.