small fixes

This commit is contained in:
kremsy 2014-02-02 19:44:33 +01:00 committed by Steffen Schröder
parent 995c820e44
commit a66309c745

View File

@ -6,17 +6,22 @@
$host = "localhost"; $host = "localhost";
$port = 3306; $port = 3306;
$user = "maniacontrol";
$dbname = "convert_test"; $targetUser = "smparagon";
$pass = "kjhgvhbjnfih2394ugnjk"; $targetDb = "maniacontrol_1337";
$targetPass = "";
$user = "smesc1";
$dbname = "smesc2";
$pass = "";
$converter = new DatabaseConverter($host, $port, $user, $pass, $dbname); $converter = new DatabaseConverter($host, $port, $targetUser, $targetPass, $targetDb);
$converter->connectToSourceDB($host, $port, $user, $pass, "smesc12"); $converter->connectToSourceDB($host, $port, $user, $pass, $dbname);
$test = $converter->convertPlayersAndStatistics(); $test1 = $converter->convertPlayersAndStatistics();
$test = $converter->convertMapsAndKarma(); $test2 = $converter->convertMapsAndKarma();
unset($converter); unset($converter);
var_dump($test); var_dump($test1 && $test2);
class DatabaseConverter { class DatabaseConverter {
/** /**
@ -170,10 +175,10 @@ class DatabaseConverter {
$result->free_result(); $result->free_result();
//SELECT Login, Uid, Score FROM `rs_karma` INNER JOIN `maps` ON (maps.id = rs_karma.id) INNER JOIN `players` ON (players.Id = rs_karma.PlayerId); //SELECT Login, Uid, Score FROM `rs_karma` INNER JOIN `players` ON (players.Id = rs_karma.PlayerId) LEFT JOIN `maps` ON (maps.id = rs_karma.MapId)
//Get Karma Table //Get Karma Table
$karmaQuery = "SELECT Login, Uid, Score FROM `" . self::AS_TABLE_KARMA . "` $karmaQuery = "SELECT Login, Uid, Score FROM `" . self::AS_TABLE_KARMA . "`
INNER JOIN `" . self::AS_TABLE_MAPS . "` ON (" . self::AS_TABLE_MAPS . ".id = " . self::AS_TABLE_KARMA . ".id) LEFT JOIN `" . self::AS_TABLE_MAPS . "` ON (" . self::AS_TABLE_MAPS . ".id = " . self::AS_TABLE_KARMA . ".MapId)
INNER JOIN `" . self::AS_TABLE_PLAYERS . "` ON (" . self::AS_TABLE_PLAYERS . ".Id = " . self::AS_TABLE_KARMA . ".PlayerId);"; INNER JOIN `" . self::AS_TABLE_PLAYERS . "` ON (" . self::AS_TABLE_PLAYERS . ".Id = " . self::AS_TABLE_KARMA . ".PlayerId);";
$result = $this->sourceMysqli->query($karmaQuery); $result = $this->sourceMysqli->query($karmaQuery);
@ -193,6 +198,9 @@ class DatabaseConverter {
//Loop through all the players //Loop through all the players
while($row = $result->fetch_object()) { while($row = $result->fetch_object()) {
if (!isset($mapvector[$row->Uid])) {
continue;
}
$mapId = intval($mapvector[$row->Uid]); $mapId = intval($mapvector[$row->Uid]);
$playerId = intval($playerVector[$row->Login]); $playerId = intval($playerVector[$row->Login]);
$vote = 1; $vote = 1;