Example #1
0
$defenseColNames = implode(" + ", $defenseColNames);
$military = array();
// zuerst Einheiten aus der Tabelle 'Cave' einfuegen
$query = "SELECT playerID, SUM(" . $unitColNames . " + " . $defenseColNames . ") AS military" . " FROM Cave" . " GROUP BY playerID" . " HAVING playerID != 0";
$db_unit_standing = $db->query($query);
if (!$db_unit_standing) {
    echo "Fehler beim Auslesen in Schritt (1.a.i)\r\n";
    return -3;
}
while ($row = $db_unit_standing->nextrow()) {
    $military[$row['playerID']] += $row['military'];
}
// dann Einheiten aus der Tabelle 'Event_Movement' dazu addieren
$movingUnitColNames = array();
for ($i = 0; $i < sizeof($unitTypeList); ++$i) {
    array_push($movingUnitColNames, unit_rating($unitTypeList[$i]) . " * m." . $unitTypeList[$i]->dbFieldName);
}
$movingUnitColNames = implode(" + ", $movingUnitColNames);
$query = "SELECT c.playerID, m.caveID," . " SUM(" . $movingUnitColNames . ") AS military" . " FROM Event_movement m LEFT JOIN Cave c ON c.caveID = m.caveID" . " GROUP BY m.caveID" . " HAVING caveID != 0";
$db_unit_movement = $db->query($query);
if (!$db_unit_movement) {
    echo "Fehler beim Auslesen in Schritt (1.a.ii)\r\n";
    return -4;
}
while ($row = $db_unit_movement->nextrow()) {
    $military[$row['playerID']] += $row['military'];
}
// military ranking
// first delete banned players from ranking
$military = unsetBanned($military, $banned_players);
$maxval = max($military) / 10000;
Example #2
0
if (!$sql->execute()) {
    echo "Fehler beim Auslesen in Schritt (1.a.i)\n";
    return -3;
}
while ($row = $sql->fetch(PDO::FETCH_ASSOC)) {
    if (!isset($military[$row['playerID']])) {
        $military[$row['playerID']] = $row['military'];
    } else {
        $military[$row['playerID']] += $row['military'];
    }
}
$sql->closeCursor();
// dann Einheiten aus der Tabelle 'Event_Movement' dazu addieren
$movingUnitColNames = array();
for ($i = 0; $i < sizeof($GLOBALS['unitTypeList']); ++$i) {
    array_push($movingUnitColNames, unit_rating($GLOBALS['unitTypeList'][$i]) . " * m." . $GLOBALS['unitTypeList'][$i]->dbFieldName);
}
$movingUnitColNames = implode(" + ", $movingUnitColNames);
$sql = $db->prepare("SELECT c.playerID, m.caveID, SUM(" . $movingUnitColNames . ") AS military\n                     FROM " . EVENT_MOVEMENT_TABLE . " m\n                       LEFT JOIN " . CAVE_TABLE . " c ON c.caveID = m.caveID\n                     GROUP BY m.caveID\n                     HAVING caveID != 0");
if (!$sql->execute()) {
    echo "Fehler beim Auslesen in Schritt (1.a.ii)\n";
    return -4;
}
while ($row = $sql->fetch(PDO::FETCH_ASSOC)) {
    if (!isset($military[$row['playerID']])) {
        $military[$row['playerID']] = $row['military'];
    } else {
        $military[$row['playerID']] += $row['military'];
    }
}
$sql->closeCursor();