/** * Changes the ships of a fleet. * * @param array associative array */ public function updateShips($ships) { $fleet = $this->fleet; $changedShips = Spec::diff($fleet, $ships); $inserts = ""; $deletes = ""; foreach ($changedShips as $specID => $shipCount) { // add/change if (!empty($specID)) { if ($shipCount > 0) { if (!empty($inserts)) { $inserts .= ","; } $inserts .= "(" . $this->fleetID . ", " . $specID . ", " . $shipCount . ")"; } else { if (!empty($deletes)) { $deletes .= ","; } $deletes .= "(" . $this->fleetID . ", " . $specID . ")"; } } if (!$shipCount) { unset($fleet[$specID]); } else { $fleet[$specID] = $shipCount; } } $this->fleet = $fleet; if (!empty($inserts)) { $sql = "REPLACE INTO ugml_fleet_spec\n\t\t\t\t\t(fleetID, specID, shipCount)\n\t\t\t\t\tVALUES " . $inserts; WCF::getDB()->sendQuery($sql); } if (!empty($deletes)) { $sql = "DELETE FROM ugml_fleet_spec\n\t\t\t\t\tWHERE (fleetID, specID) IN (" . $deletes . ")"; WCF::getDB()->sendQuery($sql); } FleetLog::update($this->getObject()); }
/** * Logs this object. */ public function execute($data) { parent::execute($data); $this->addData(array('thispr' => print_r($this, true))); FleetLog::update($this); }