/** * Update the summary table when a kill value changes. * * @param Kill $kill * @param float $difference */ public static function update($kill, $difference) { $year = date('Y', strtotime($kill->getTimestamp())); $month = date('m', strtotime($kill->getTimestamp())); $shipid = $kill->getVictimShip()->getClass()->getID(); $difference = (double) $difference; $alls = array(); $qry = DBFactory::getDBQuery(); $sql = "UPDATE kb3_sum_alliance SET asm_loss_isk = asm_loss_isk + " . $difference . " WHERE asm_all_id = " . $kill->getVictimAllianceID() . " AND asm_shp_id = " . $shipid; $qry->execute($sql); foreach ($kill->getInvolved() as $inv) { if (isset($alls[$inv->getAllianceID()])) { continue; } $alls[$inv->getAllianceID()] = 1; $qry->execute("SELECT 1 FROM kb3_sum_alliance WHERE asm_all_id = " . $inv->getAllianceID()); if (!$qry->recordCount()) { continue; } $sql = "UPDATE kb3_sum_alliance SET asm_kill_isk = asm_kill_isk + " . $difference . " WHERE asm_all_id = " . $inv->getAllianceID() . " AND asm_shp_id = " . $shipid; $qry->execute($sql); } }
/** * Update the summary table when a kill value changes. * * @param Kill $kill * @param float $difference */ public static function update($kill, $difference) { $difference = (double) $difference; $alls = array(); $qry = DBFactory::getDBQuery(); $qry->execute("SELECT 1 FROM kb3_sum_pilot WHERE psm_plt_id = " . $kill->getVictimID()); // No summary table to remove kill from so skip. if ($qry->recordCount()) { $sql = "UPDATE kb3_sum_pilot SET psm_loss_isk = psm_loss_isk - " . $difference . " WHERE psm_plt_id = " . $kill->getVictimID() . " AND psm_shp_id = " . $kill->getVictimShip()->getClass()->getID(); $qry->execute($sql); } foreach ($kill->getInvolved() as $inv) { if ($alls[$inv->getPilotID()]) { continue; } $alls[$inv->getPilotID()] = 1; $qry->execute("SELECT 1 FROM kb3_sum_pilot WHERE psm_plt_id = " . $inv->getPilotID()); if (!$qry->recordCount()) { continue; } $sql = "UPDATE kb3_sum_pilot SET psm_kill_isk = psm_kill_isk - " . $difference . " WHERE psm_plt_id = " . $inv->getPilotID() . " AND psm_shp_id = " . $kill->getVictimShip()->getClass()->getID(); $qry->execute($sql); } }