#!/usr/bin/perl

use warnings;
use strict;

use DBI;

use vars qw($debug %pnumloc);

$debug = 0;

my $dbuser = "skolelinux_no";
my $dbname = "skolelinux_no";
my $dbpass = "wpg89";

sub showOrKill {
    my $command = shift;
    my $id = shift;

    my $dbh = DBI->connect("DBI:mysql:$dbname", $dbuser, $dbpass);
    if ($command eq "remove")
    {
       my $sql = "UPDATE school SET deleted = 1 where school_id = $id";
       $dbh->do($sql);
       print "SQL: $sql\n";     
    }   
    elsif ($command eq "show")
    {
       my $sql = "UPDATE school SET deleted = 0 where school_id = $id";
       $dbh->do($sql);
       print "SQL: $sql\n";   
    }
    else
    {
       print "Command $command not implemented yet\n";
    }   
#    print "SQL: $sql\n";
    
    $dbh->disconnect();
}
if (2 == @ARGV) {
    showOrKill(@ARGV);
} else {
    print "Usage: $0 [show|remove] [id] \n(Show or delete school with given ID)\n";
}
