db converter improvements

This commit is contained in:
kremsy 2014-03-11 17:04:38 +01:00 committed by Steffen Schröder
parent 0fac5e7f4d
commit 49805f06b3

View File

@ -20,20 +20,25 @@ $sourceUser = "maniacontrol";
$sourceDb = "smesc12"; $sourceDb = "smesc12";
$sourcePass = ""; $sourcePass = "";
//Convert Hits to Kills (means each Hit gets Converted to one Kill //Convert Hits to Kills (means each Hit gets Converted to one Kill)
$convertHitsToKills = true; $convertHitsToKills = false;
$convertHitsToLaserHits = true; //Convert 2 Hits to Kills (means two Hits gets Converted to one Kill)
$convertShotsToLaserShots = true; $convertTwoHitsToOneKill = true;
//Convert all Hits to Laser Hits
$convertHitsToLaserHits = false;
//Convert all Shots to Laser Shots
$convertShotsToLaserShots = false;
//Settings END //Settings END
$converter = new DatabaseConverter($host, $port, $targetUser, $targetPass, $targetDb); $converter = new DatabaseConverter($host, $port, $targetUser, $targetPass, $targetDb);
$converter->connectToSourceDB($host, $port, $sourceUser, $sourcePass, $sourceDb); $converter->connectToSourceDB($host, $port, $sourceUser, $sourcePass, $sourceDb);
$converter->convertHitsToKills = $convertHitsToKills; $converter->convertHitsToKills = $convertHitsToKills;
$converter->convertHitsToLaserHits = $convertHitsToLaserHits; $converter->convertTwoHitsToOneKill = $convertTwoHitsToOneKill;
$converter->convertHitsToLaserHits = $convertHitsToLaserHits;
$converter->convertShotsToLaserShots = $convertShotsToLaserShots; $converter->convertShotsToLaserShots = $convertShotsToLaserShots;
$test1 = $converter->convertPlayersAndStatistics(); $test1 = $converter->convertPlayersAndStatistics();
$test2 = $converter->convertMapsAndKarma(); $test2 = $converter->convertMapsAndKarma();
unset($converter); unset($converter);
var_dump($test1 && $test2); var_dump($test1 && $test2);
@ -55,6 +60,7 @@ class DatabaseConverter { //TODO move bind param before loop everywhere, convert
* Public properties * Public properties
*/ */
public $convertHitsToKills = true; public $convertHitsToKills = true;
public $convertTwoHitsToOneKill = true;
public $convertHitsToLaserHits = true; public $convertHitsToLaserHits = true;
public $convertShotsToLaserShots = true; public $convertShotsToLaserShots = true;
@ -391,7 +397,12 @@ class DatabaseConverter { //TODO move bind param before loop everywhere, convert
$statStatement->bind_param('iiii', $row->Id, $statId, $row->Hits, $serverIndex); $statStatement->bind_param('iiii', $row->Id, $statId, $row->Hits, $serverIndex);
$statStatement->execute(); $statStatement->execute();
if ($this->convertHitsToKills) { if ($this->convertTwoHitsToOneKill){
$statId = 12;
$kills = $row->Hits / 2;
$statStatement->bind_param('iiii', $row->Id, $statId, $kills, $serverIndex);
$statStatement->execute();
} else if ($this->convertHitsToKills) {
$statId = 12; $statId = 12;
$statStatement->bind_param('iiii', $row->Id, $statId, $row->Hits, $serverIndex); $statStatement->bind_param('iiii', $row->Id, $statId, $row->Hits, $serverIndex);
$statStatement->execute(); $statStatement->execute();