1 package C4::Database; #asummes C4/Database
3 #requires DBI.pm to be installed
8 use vars qw($VERSION @ISA @EXPORT);
14 &C4Connect &requireDBI
20 my ($database,$hostname,$user,$pass,%configfile);
21 open (KC, "/etc/koha.conf");
25 if (/(.*)\s*=\s*(.*)/) {
28 # Clean up white space at beginning and end
33 $configfile{$variable}=$value;
36 $database=$configfile{'database'};
37 $hostname=$configfile{'hostname'};
38 $user=$configfile{'user'};
39 $pass=$configfile{'pass'};
41 my $dbh=DBI->connect("DBI:mysql:$database:$hostname",$user,$pass);
46 # Helper subroutine to make sure database handle was passed properly
50 $subrname, # name of calling subroutine
53 unless ( ref($dbh) =~ /DBI::db/ ) {
54 print "<pre>\nERROR: Subroutine $subrname called without proper DBI handle.\n" .
55 "Please contact system administrator.\n</pre>\n";
56 die "ERROR: Subroutine $subrname called without proper DBI handle.\n";