#!/usr/bin/perl BEGIN { use lib '/usr/home/cfg' ; require push_inc ; } require cfg ; use CGI::Carp qw(fatalsToBrowser); # use Date::Calc qw(:all); # use DBI; # https://itvadmin.co.za/cgi-bin/scripts/admin/oneoff/cities_fix_db.pl?1 #------------------------------------------------------------------------------- my @ARGV = split(/\&/, $ENV{'QUERY_STRING'}); our $debug = $ARGV[0] ; # our $username = 'rory' ; if ($debug) { print "Content-type: text/html\n\n"; } #------------------------------------------------------------------------------------------ &today ; &db_open_upd ; # &db_open_ro ; our $db_ignore_open_close = 1 ; # do one open and one close instead of repeating it &load_vars ; $db_ignore_open_close = 0 ; # do one open and one close instead of repeating it &db_close_conn ; if ($debug) { print "Done."; } exit; #------------------------------------------------------------------------------------------ sub load_vars { &db_min_ro('event_quotes','id,city_id',"city_id > 0",'','') ; foreach my $_id (sort {$a <=> $b} keys %{$db{event_quotes}}) { $got_city{$db{event_quotes}{$_id}{city_id}} .= $_id . '|' ; } &db_min_ro('cities','id,city','','','') ; foreach my $_id (sort {$a <=> $b} keys %{$db{cities}}) { # print $db{cities}{$_id}{city} . "[$got_city{$_id}]" . '
' unless $got_city{$_id} ; &db_min_delete('cities',"id = '$_id'") unless $got_city{$_id} ; } } #------------------------------------------------------------------------------- use db ; use today ; use common ; use common_min ;