Loading...   


use DBI;
use DBD::mysql;
# CONFIG VARIABLES - Parsed from eqemu_config.xml
my $confile = "eqemu_config.xml"; #default
open(F, "<$confile") or die "Unable to open config: $confile\n";
my $indb = 0;

# ALTER TABLE `altadv_vars`
# ADD COLUMN `sof_last_id`  int(11) NOT NULL DEFAULT 0 AFTER `sof_current_level`,
# DROP PRIMARY KEY,
# ADD PRIMARY KEY (`skill_id`, `spellid`);

while(<F>) {
	s/\r//g;
	if(/<database>/i) { $indb = 1; }
	next unless($indb == 1);
	if(/<\/database>/i) { $indb = 0; last; }
	if(/<host>(.*)<\/host>/i) { $host = $1; } 
	elsif(/<username>(.*)<\/username>/i) { $user = $1; } 
	elsif(/<password>(.*)<\/password>/i) { $pass = $1; } 
	elsif(/<db>(.*)<\/db>/i) { $db = $1; }
}

# PERL DBI CONNECT
$dsn = "dbi:mysql:$db:localhost:3306";
if(!$connect){ $connect = DBI->connect($dsn, $user, $pass); }
if(!$connect2){ $connect2 = DBI->connect($dsn, $user, $pass); }

$query_handle = $connect->prepare("SELECT `skill_id`, `name`, `sof_next_id` FROM `altadv_vars`"); $query_handle->execute();
while(@row = $query_handle->fetchrow_array()){
	$alt_adv_ref[$row[0]] = $row[1];
}

$n = 0;
$query_handle = $connect->prepare("SELECT `skill_id`, `name`, `sof_next_id` FROM `altadv_vars`"); $query_handle->execute();
while(@row = $query_handle->fetchrow_array()){
	my ($skill_id, $name, $sof_next_id) = ($row[0], $row[1], $row[2]);
	# print $skill_id . ' ' . $name . ' SOF_NEXT_ID: ' . $sof_next_id . "\n";
	if($sof_next_id > 0){
		print " -- SET '" . $alt_adv_ref[$sof_next_id] . "' to SOF_LAST_ID (" . $row[0] . ") '" . $name . "' -- \n";
		print "UPDATE `altadv_vars` SET `sof_last_id` = " . $row[0] . " WHERE `skill_id` = " . $sof_next_id . ";\n";
	}
}

Raw Paste Data