lib = $lib; $this->db = $this->lib->game->db; } public function run($player, $requests) { // Delete the player's requests $this->db->query("DELETE FROM tech_trade_request WHERE player = $player"); // Get the player's alliance; if we're here, then the player *is* in an alliance $q = $this->db->query("SELECT alliance FROM player WHERE id = $player"); list($alliance) = dbFetchArray($q); // Delete the player's requests and reinserts them while removing any tech that is now "seen" $this->db->query("DELETE FROM tech_trade_request WHERE player = $player"); $prio = 0; foreach ($requests as $req) { $this->db->query( "INSERT INTO tech_trade_request (alliance, player, priority, tech) " . "VALUES ($alliance, $player, $prio, $req)" ); $prio ++; } } } ?>