Перешли с неё на UTM, отконвертировав юзеров из одной системы в другую.
Конвертация производилась сим скриптом.
Может кому пригодится, чтобы взять за основу.
Имхо, может пригодиться при переходе с других систем.
Имеется несколько групп юзеров, one .. ten.
Каждый юзер сидит в какой-то группе.
На каждую группу приходится по тарифу, включающему в себя услугу ип-траффик.
В некоторые тарифы ещё входит периодическая услуга в лице абонплаты.
Группы, услуги, тарифы и учетные периоды заводятся заранее.
А потом ниже в соответствии всему этому указываются номера.
Скрипт выполняется или при выключенной utm5_core или при вклюенной, но после отработки скрипта надо будет сделать killall -HUP utm5_core.
В любом случае после отработки скрипта при запуске utm5_core нужно будет глянуть, не появился ли verificator.log.
Код: Выделить всё
#!/usr/bin/perl
## Подготовка
# Инициализация используемых модулев
use DBD::mysql;
use DBI();
use Time::Local;
use Socket;
# Инициализация системных переменных
$stgdir = '/usr/local/stargazer/users';
$, = ' ';
$debug = 0;
$ids{'услуга, трафик, 7'} = 22;
$ids{'услуга, абонплата, 7'} = 21;
$ids{'услуга, трафик, 8'} = 23;
$ids{'услуга, абонплата, 8'} = 24;
$ids{'услуга, трафик, 10'} = 25;
$ids{'услуга, абонплата, 10'} = 26;
$ids{'услуга, трафик, 11'} = 27;
$ids{'услуга, абонплата, 11'} = 0;
$ids{'услуга, трафик, 12'} = 28;
$ids{'услуга, абонплата, 12'} = 0;
$ids{'Тариф, one'} = 7;
$ids{'Тариф, two'} = 8;
$ids{'Тариф, three'} = 8;
$ids{'Тариф, four'} = 10;
$ids{'Тариф, fife'} = 11;
$ids{'Тариф, six'} = 11;
$ids{'Тариф, seven'} = 11;
$ids{'Тариф, eight'} = 11;
$ids{'Тариф, nine'} = 12;
$ids{'Тариф, ten'} = 12;
$ids{'Временной диапазон, All day'} = 1;
$ids{'Расчетный период, ежедневный'} = 1;
$ids{'Расчетный период, ежемесячный'} = 3;
$ids{'admin'} = -1;
$ids{'Группа, one'} = 1001;
$ids{'Группа, two'} = 1002;
$ids{'Группа, three'} = 1004;
$ids{'Группа, four'} = 1003;
$ids{'Группа, fife'} = 1005;
$ids{'Группа, six'} = 1009;
$ids{'Группа, seven'} = 1006;
$ids{'Группа, eight'} = 1007;
$ids{'Группа, nine'} = 1008;
($day, $month, $year) = (localtime)[3,4,5];
$year += 1900;
$month++;
$month = '0'.int($month) if ($month < 10);
$day = '0'.int($day) if ($day < 10);
$date = "$year.$month.$day";
# Инициализация переменных UTM
open (CONFIG, "/netup/utm5/utm5.cfg");
@config = <CONFIG>;
close (CONFIG);
foreach $line (@config) {
if ($line =~ m/^([^#].+?)=(.*)$/) {
$$1 = $2;
};
};
# Подключение к БД
if ($database_type eq "mysql") {
$DBI_data="DBI:$database_type:database=$database;host=$database_host;mysql_socket=$database_sock_path;";
} elsif ($database_type eq "postgres") {
$DBI_data="DBI:$database_type:dbname=$database";
} else {
print "Unknown database $database_type! Stopped. \n";
exit (1);
};
$dbh = DBI->connect("$DBI_data","$database_login","$database_password",{'RaiseError' => 1});
# Обработка всех имеющихся юзеров
opendir USERS, $stgdir or die "$!";
@users = readdir USERS;
closedir USERS;
foreach $user (@users)
{
undef %b;
undef %l;
undef %a;
undef %p;
undef %m;
undef %c;
undef %t;
undef %f;
undef %n;
undef %g;
undef %r;
undef %h;
undef %o;
undef %i;
undef %w;
undef %j;
undef %x;
undef %q;
undef %k;
undef %y;
undef %z;
undef %s;
undef %d;
next if ($user eq '.' or $user eq '..');
next unless ( -d "$stgdir/$user");
# Чтение данных о юзере
undef %conf;
undef %stat;
open CONF, "iconv -f koi8-r -t utf-8 < $stgdir/$user/conf |" or die "$!";
while ($line=<CONF>)
{
chomp $line;
($name, $value) = split /=/, $line, 2;
$conf{$name} = $value;
}
close CONF;
open STAT, "< $stgdir/$user/stat" or die "$!";
while ($line=<STAT>)
{
chomp $line;
($name, $value) = split /=/, $line, 2;
$stat{$name} = $value;
}
close STAT;
## Создание лицевого счёта
# accounts
$b{'BALANCE'} = $stat{'Cash'};
$b{'COMMENTS'} = 'Account from STG';
$b{'CREDIT'} = $conf{'Credit'};
$b{'PERIOD_ID'} = $ids{'Расчетный период, ежемесячный'};
$b{'ONLINE'} = $conf{'AlwaysOnline'};
$l{'balance'} = $b{'BALANCE'}; # Бабки
$l{'account_name'} = $b{'COMMENTS'}; # Необязательное имя
$l{'credit'} = $b{'CREDIT'}; # Кредит
$l{'flags'} = $b{'PERIOD_ID'}; # id учетного периода
$l{'discount_period_id'}= '0'; # Вроде должен этот быть
$l{'is_blocked'} = '0';
$l{'dealer_account_id'} = '0';
$l{'comission_coef'} = '0';
$l{'default_comission_value'} = '0';
$l{'is_dealer'} = '0';
$l{'vat_rate'} = '0';
$l{'sale_tax_rate'} = '0';
$l{'int_status'} = $b{'ONLINE'};
$l{'dont_charge_if_block'} = '0';
$l{'block_recalc_abon'} = '0';
$l{'block_recalc_prepaid'} = '0';
$l{'unlimited'} = '0';
$l{'is_deleted'} = '0';
#get $l{'id'} with last_insert_id()
$table = 'accounts';
print "\nTABLE: $table\n" if ($debug);
$order_into = '';
$order_values = '';
while (($tmp1, $tmp2) = each %l)
{
$order_into .= "$tmp1, ";
$order_values .= "'$tmp2', ";
}
$order_into =~ s/, $//;
$order_values =~ s/, $//;
$query = "INSERT INTO $table ($order_into) VALUES ($order_values);";
print $query."\n" if ($debug);
$sth = $dbh->do($query);
$query = "SELECT last_insert_id();";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$l{'id'} = ($sth->fetchrow_array)[0];
print "ID: $l{'id'}\n" if ($debug);
## Создание учётной записи абонента
# users
$a{'LOGIN'} = $user;
$a{'PASSWORD'} = $conf{'Password'};
$a{'ACCOUNT_ID'} = $l{'id'};
$a{'BLOCK'} = '0';
$a{'PERIOD_ID'} = $ids{'Расчетный период, ежемесячный'};# id учетного периода
$a{'FULL_NAME'} = $conf{'RealName'};
$a{'JUR_ADDR'} = $conf{'Address'};
$a{'ACT_ADDR'} = $conf{'Address'};
$a{'PHONE'} = $conf{'Phone'};
$a{'EMAIL'} = $conf{'Email'};
$p{'login'} = $a{'LOGIN'};
$p{'password'} = $a{'PASSWORD'};
$p{'basic_account'} = $a{'ACCOUNT_ID'};
$p{'is_blocked'} = $a{'BLOCK'};
$p{'discount_period_id'} = '1';
$p{'advance_payment'} = '1'; # Работа по предоплате
$p{'create_date'} = time;
$p{'last_change_date'} = time;
$p{'who_create'} = $ids{'admin'}; # system user init
$p{'who_change'} = $ids{'admin'}; # system user init
$p{'is_juridical'} = '0'; # Юридическое ли лицо
$p{'full_name'} = $a{'FULL_NAME'};
$p{'juridical_address'} = $a{'JUR_ADDR'};
$p{'actual_address'} = $a{'ACT_ADDR'};
$p{'work_telephone'} = '';
$p{'home_telephone'} = $a{'PHONE'};
$p{'mobile_telephone'} = '';
$p{'web_page'} = '';
$p{'icq_number'} = '';
$p{'tax_number'} = '';
$p{'kpp_number'} = '';
$p{'bank_id'} = '0';
$p{'bank_account'} = '';
$p{'email'} = $a{'EMAIL'};
$p{'house_id'} = '0';
$p{'flat_number'} = '';
$p{'entrance'} = '';
$p{'floor'} = '';
$p{'district'} = '';
$p{'building'} = '';
$p{'passport'} = '';
$p{'comments'} = '';
$p{'personal_manager'} = '';
$p{'connect_date'} = '-43200';
$p{'remote_switch_id'} = '0';
$p{'port_number'} = '0';
$p{'personal_currency_coef'} = '1';
$p{'binded_currency_code'} = '810';
$p{'is_deleted'} = '0';
$p{'is_send_invoice'} = '0';
#get $p{'id'} with last_insert_id()
$table = 'users';
print "\nTABLE: $table\n" if ($debug);
$order_into = '';
$order_values = '';
while (($tmp1, $tmp2) = each %p)
{
$order_into .= "$tmp1, ";
$order_values .= "'$tmp2', ";
}
$order_into =~ s/, $//;
$order_values =~ s/, $//;
$query = "INSERT INTO $table ($order_into) VALUES ($order_values);";
print $query."\n" if ($debug);
$sth = $dbh->do($query);
$query = "SELECT last_insert_id();";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$p{'id'} = ($sth->fetchrow_array)[0];
print "ID: $p{'id'}\n" if ($debug);
# users_accounts
$m{'uid'} = $p{'id'}; # id юзера
$m{'account_id'} = $l{'id'}; # id лицевого счета
$m{'is_deleted'} = '0';
#get $m{'id'} with last_insert_id()
$table = 'users_accounts';
print "\nTABLE: $table\n" if ($debug);
$order_into = '';
$order_values = '';
while (($tmp1, $tmp2) = each %m)
{
$order_into .= "$tmp1, ";
$order_values .= "'$tmp2', ";
}
$order_into =~ s/, $//;
$order_values =~ s/, $//;
$query = "INSERT INTO $table ($order_into) VALUES ($order_values);";
print $query."\n" if ($debug);
$sth = $dbh->do($query);
$query = "SELECT last_insert_id();";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$m{'id'} = ($sth->fetchrow_array)[0];
print "ID: $m{'id'}\n" if ($debug);
# users_groups_link
$d{'USER_ID'} = $p{'id'};
$d{'GROUP_ID'} = $ids{"Группа, $conf{Group}"};
$s{'user_id'} = $d{'USER_ID'};
$s{'group_id'} = $d{'GROUP_ID'};
#get $s{'id'} with last_insert_id()
$table = 'users_groups_link';
print "\nTABLE: $table\n" if ($debug);
$order_into = '';
$order_values = '';
while (($tmp1, $tmp2) = each %s)
{
$order_into .= "$tmp1, ";
$order_values .= "'$tmp2', ";
}
$order_into =~ s/, $//;
$order_values =~ s/, $//;
$query = "INSERT INTO $table ($order_into) VALUES ($order_values);";
print $query."\n" if ($debug);
$sth = $dbh->do($query);
$query = "SELECT last_insert_id();";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$s{'id'} = ($sth->fetchrow_array)[0];
print "ID: $s{'id'}\n" if ($debug);
## Привязка тарифного плана к лицевому счёту абонента
# account_tariff_link
$c{'TARIFF_ID'} = $ids{"Тариф, $conf{Group}"}; # id тарифного плана
$c{'PERIOD_ID'} = $ids{'Расчетный период, ежемесячный'};# id расчётного периода
$t{'account_id'} = $l{'id'};
$t{'tariff_id'} = $c{'TARIFF_ID'};
$t{'next_tariff_id'} = $c{'TARIFF_ID'};
$t{'discount_period_id'}= $c{'PERIOD_ID'};
$t{'is_deleted'} = '0';
$t{'link_date'} = time;
#get $t{'id'} with last_insert_id()
$table = 'account_tariff_link';
print "\nTABLE: $table\n" if ($debug);
$order_into = '';
$order_values = '';
while (($tmp1, $tmp2) = each %t)
{
$order_into .= "$tmp1, ";
$order_values .= "'$tmp2', ";
}
$order_into =~ s/, $//;
$order_values =~ s/, $//;
$query = "INSERT INTO $table ($order_into) VALUES ($order_values);";
print $query."\n" if ($debug);
$sth = $dbh->do($query);
$query = "SELECT last_insert_id();";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$t{'id'} = ($sth->fetchrow_array)[0];
print "ID: $t{'id'}\n" if ($debug);
## Привязка услуги передачи IP-трафика из тарифного плана к лицевому счету
# service_links
$table = 'service_links';
print "\nTABLE: $table\n" if ($debug);
$query = "SELECT max(id) from $table;";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$f{'SLINK_ID'} = ($sth->fetchrow_array)[0];
$f{'SLINK_ID'} ++;
print "IP-traffic SLINK_ID: $f{'SLINK_ID'}\n" if ($debug);
$f{'SERVICE_ID'} = $ids{"услуга, трафик, $c{'TARIFF_ID'}"}; # id услуги
$n{'id'} = $f{'SLINK_ID'}; # SLINK_ID
$n{'user_id'} = $p{'id'}; # id юзера
$n{'account_id'} = $l{'id'}; # id лицевого счета
$n{'service_id'} = $f{'SERVICE_ID'};
$n{'tariff_link_id'} = $t{'id'};
$n{'is_deleted'} = '0';
#get $n{'id'} with last_insert_id()
$table = 'service_links';
print "\nTABLE: $table\n" if ($debug);
$order_into = '';
$order_values = '';
while (($tmp1, $tmp2) = each %n)
{
$order_into .= "$tmp1, ";
$order_values .= "'$tmp2', ";
}
$order_into =~ s/, $//;
$order_values =~ s/, $//;
$query = "INSERT INTO $table ($order_into) VALUES ($order_values);";
print $query."\n" if ($debug);
$sth = $dbh->do($query);
$query = "SELECT last_insert_id();";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$n{'id'} = ($sth->fetchrow_array)[0];
print "ID: $n{'id'}\n" if ($debug);
# periodic_service_links
$g{'PERIOD_ID'} = $ids{'Расчетный период, ежемесячный'};# id расчётного периода
$g{'SLINK_ID'} = $f{'SLINK_ID'};
$r{'id'} = $g{'SLINK_ID'};
$r{'is_blocked'} = '0';
$r{'discount_period_id'}= $g{'PERIOD_ID'};
$r{'discounted_in_curr_period'}='0';
$r{'start_date'} = '1167566400'; # 1.01.2007
$r{'is_planned'} = '0';
$r{'expire_date'} = '2130706431'; # очень нескоро
$r{'need_del'} = '0';
$r{'unabon_period'} = '0';
$r{'unprepay_period'} = '0';
$r{'start_block_unabon'}= '0';
$r{'start_block_unprepay'} = '0';
$r{'is_deleted'} = '0';
#get $r{'id'} with last_insert_id()
$table = 'periodic_service_links';
print "\nTABLE: $table\n" if ($debug);
$order_into = '';
$order_values = '';
while (($tmp1, $tmp2) = each %r)
{
$order_into .= "$tmp1, ";
$order_values .= "'$tmp2', ";
}
$order_into =~ s/, $//;
$order_values =~ s/, $//;
$query = "INSERT INTO $table ($order_into) VALUES ($order_values);";
print $query."\n" if ($debug);
$sth = $dbh->do($query);
$query = "SELECT last_insert_id();";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$r{'id'} = ($sth->fetchrow_array)[0];
print "ID: $r{'id'}\n" if ($debug);
# ip_groups
$table = 'ip_groups';
print "\nTABLE: $table\n" if ($debug);
$query = "SELECT max(ip_group_id) from $table;";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$h{'IP_GROUP_ID'} = ($sth->fetchrow_array)[0];
$h{'IP_GROUP_ID'} ++;
print "IP_GROUP_ID: $h{'IP_GROUP_ID'}\n" if ($debug);
$h{'IP'} = $conf{'IP'}; # ip-адрес клиента В ПЕРЕДЕЛАННОМ ВИДЕ
$h{'IP'} = unpack("N",inet_aton($h{'IP'}));
$h{'IP'} = $h{'IP'} > 2147483647 ? ($h{'IP'} - 0xFFFFFFFF - 1):$h{'IP'};
$h{'LOGIN'} = $user; # login юзера
$h{'PASSWORD'} = $conf{'Password'}; # pass юзера
$h{'MAC'} = $conf{'Userdata0'};
$h{'MAC'} =~ s/-/:/;
$h{'MAC'} = lc $h{'MAC'};
$o{'ip_group_id'} = $h{'IP_GROUP_ID'};
$o{'ip'} = $h{'IP'};
$o{'mask'} = '-1'; # маска подсети клиента
$o{'uname'} = $h{'LOGIN'};
$o{'upass'} = $h{'PASSWORD'};
$o{'mac'} = $h{'MAC'};
$o{'allowed_cid'} = '';
$o{'ip_type'} = '1';
$o{'router_id'} = '1';
$o{'create_date'} = time;
$o{'delete_date'} = '0';
$o{'is_deleted'} = '0';
#get $o{'id'} with last_insert_id()
$order_into = '';
$order_values = '';
while (($tmp1, $tmp2) = each %o)
{
$order_into .= "$tmp1, ";
$order_values .= "'$tmp2', ";
}
$order_into =~ s/, $//;
$order_values =~ s/, $//;
$query = "INSERT INTO $table ($order_into) VALUES ($order_values);";
print $query."\n" if ($debug);
$sth = $dbh->do($query);
$query = "SELECT last_insert_id();";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$o{'id'} = ($sth->fetchrow_array)[0];
print "ID: $o{'id'}\n" if ($debug);
# downloaded
$table = 'downloaded';
print "\nTABLE: $table\n" if ($debug);
$query = "SELECT max(downloaded_id) from $table;";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$i{'DOWNLOADED_ID'} = ($sth->fetchrow_array)[0];
$i{'DOWNLOADED_ID'} ++;
print "DOWNLOADED_ID: $i{'DOWNLOADED_ID'}\n" if ($debug);
$w{'downloaded_id'} = $i{'DOWNLOADED_ID'};
$w{'tclass_id'} = '0';
#get $w{'id'} with last_insert_id()
$order_into = '';
$order_values = '';
while (($tmp1, $tmp2) = each %w)
{
$order_into .= "$tmp1, ";
$order_values .= "'$tmp2', ";
}
$order_into =~ s/, $//;
$order_values =~ s/, $//;
$query = "INSERT INTO $table ($order_into) VALUES ($order_values);";
print $query."\n" if ($debug);
$sth = $dbh->do($query);
$query = "SELECT last_insert_id();";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$w{'id'} = ($sth->fetchrow_array)[0];
print "ID: $w{'id'}\n" if ($debug);
# iptraffic_service_links
$j{'SLINK_ID'} = $f{'SLINK_ID'};
$j{'IP_GROUP_ID'} = $h{'IP_GROUP_ID'}; # id группы ip-адреса клиента
$j{'DOWNLOADED_ID'} = $i{'DOWNLOADED_ID'};
$x{'id'} = $j{'SLINK_ID'};
$x{'ip_group_id'} = $j{'IP_GROUP_ID'};
$x{'downloaded_id'} = $j{'DOWNLOADED_ID'};
$x{'recalc_type'} = '0';
$x{'is_deleted'} = '0';
$x{'flags'} = '0';
#get $x{'id'} with last_insert_id()
$table = 'iptraffic_service_links';
print "\nTABLE: $table\n" if ($debug);
$order_into = '';
$order_values = '';
while (($tmp1, $tmp2) = each %x)
{
$order_into .= "$tmp1, ";
$order_values .= "'$tmp2', ";
}
$order_into =~ s/, $//;
$order_values =~ s/, $//;
$query = "INSERT INTO $table ($order_into) VALUES ($order_values);";
print $query."\n" if ($debug);
$sth = $dbh->do($query);
$query = "SELECT last_insert_id();";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$x{'id'} = ($sth->fetchrow_array)[0];
print "ID: $x{'id'}\n" if ($debug);
if($ids{"услуга, абонплата, $c{'TARIFF_ID'}"})
{
## Привязка периодической услуги из тарифного плана к лицевому счёту
# service_links
$table = 'service_links';
print "\nTABLE: $table\n" if ($debug);
$query = "SELECT max(id) from $table;";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$q{'SLINK_ID'} = ($sth->fetchrow_array)[0];
$q{'SLINK_ID'} ++;
print "abon SLINK_ID: $q{'SLINK_ID'}\n" if ($debug);
$q{'SERVICE_ID'} = $ids{"услуга, абонплата, $c{'TARIFF_ID'}"}; # id услуги
$k{'id'} = $q{'SLINK_ID'};
$k{'user_id'} = $p{'id'}; # id юзера
$k{'account_id'} = $l{'id'}; # id лицевого счета
$k{'service_id'} = $q{'SERVICE_ID'};
$k{'tariff_link_id'} = $t{'id'};
$k{'is_deleted'} = '0';
#get $k{'id'} with last_insert_id()
$table = 'service_links';
print "\nTABLE: $table\n" if ($debug);
$order_into = '';
$order_values = '';
while (($tmp1, $tmp2) = each %k)
{
$order_into .= "$tmp1, ";
$order_values .= "'$tmp2', ";
}
$order_into =~ s/, $//;
$order_values =~ s/, $//;
$query = "INSERT INTO $table ($order_into) VALUES ($order_values);";
print $query."\n" if ($debug);
$sth = $dbh->do($query);
$query = "SELECT last_insert_id();";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$k{'id'} = ($sth->fetchrow_array)[0];
print "ID: $k{'id'}\n" if ($debug);
# periodic_service_links
$y{'PERIOD_ID'} = $ids{'Расчетный период, ежемесячный'};# id расчётного периода
$y{'SLINK_ID'} = $q{'SLINK_ID'};
$z{'id'} = $y{'SLINK_ID'};
$z{'is_blocked'} = '0';
$z{'discount_period_id'}= $y{'PERIOD_ID'};
$z{'discounted_in_curr_period'}='0';
$z{'start_date'} = '1167566400'; # 1.01.2007
$z{'is_planned'} = '0';
$z{'expire_date'} = '2130706431'; # очень нескоро
$z{'need_del'} = '0';
$z{'unabon_period'} = '0';
$z{'unprepay_period'} = '0';
$z{'start_block_unabon'}= '0';
$z{'start_block_unprepay'} = '0';
$z{'is_deleted'} = '0';
#get $z{'id'} with last_insert_id()
$table = 'periodic_service_links';
print "\nTABLE: $table\n" if ($debug);
$order_into = '';
$order_values = '';
while (($tmp1, $tmp2) = each %z)
{
$order_into .= "$tmp1, ";
$order_values .= "'$tmp2', ";
}
$order_into =~ s/, $//;
$order_values =~ s/, $//;
$query = "INSERT INTO $table ($order_into) VALUES ($order_values);";
print $query."\n" if ($debug);
$sth = $dbh->do($query);
$query = "SELECT last_insert_id();";
print $query."\n" if ($debug);
$sth = $dbh->prepare($query);
$rv = $sth->execute();
$z{'id'} = ($sth->fetchrow_array)[0];
print "ID: $z{'id'}\n" if ($debug);
}
}