Lines 97-103
BEGIN {
Link Here
|
97 |
$VERSION = '3.07.00.049'; |
97 |
$VERSION = '3.07.00.049'; |
98 |
} |
98 |
} |
99 |
|
99 |
|
100 |
use DBIx::Connector; |
|
|
101 |
use Encode; |
100 |
use Encode; |
102 |
use ZOOM; |
101 |
use ZOOM; |
103 |
use XML::Simple; |
102 |
use XML::Simple; |
Lines 726-780
sub _new_Zconn {
Link Here
|
726 |
sub _new_dbh |
725 |
sub _new_dbh |
727 |
{ |
726 |
{ |
728 |
|
727 |
|
729 |
## $context |
728 |
Koha::Database->schema->storage->dbh; |
730 |
## correct name for db_scheme |
|
|
731 |
my $db_driver = $context->{db_driver}; |
732 |
|
733 |
my $db_name = $context->config("database"); |
734 |
my $db_host = $context->config("hostname"); |
735 |
my $db_port = $context->config("port") || ''; |
736 |
my $db_user = $context->config("user"); |
737 |
my $db_passwd = $context->config("pass"); |
738 |
# MJR added or die here, as we can't work without dbh |
739 |
my $dbh = DBIx::Connector->connect( |
740 |
"dbi:$db_driver:dbname=$db_name;host=$db_host;port=$db_port", |
741 |
$db_user, $db_passwd, |
742 |
{ |
743 |
'RaiseError' => $ENV{DEBUG} ? 1 : 0 |
744 |
} |
745 |
); |
746 |
|
747 |
# Check for the existence of a systempreference table; if we don't have this, we don't |
748 |
# have a valid database and should not set RaiseError in order to allow the installer |
749 |
# to run; installer will not run otherwise since we raise all db errors |
750 |
|
751 |
eval { |
752 |
local $dbh->{PrintError} = 0; |
753 |
local $dbh->{RaiseError} = 1; |
754 |
$dbh->do(qq{SELECT * FROM systempreferences WHERE 1 = 0 }); |
755 |
}; |
756 |
|
757 |
if ($@) { |
758 |
$dbh->{RaiseError} = 0; |
759 |
} |
760 |
|
761 |
if ( $db_driver eq 'mysql' ) { |
762 |
$dbh->{mysql_auto_reconnect} = 1; |
763 |
} |
764 |
|
765 |
my $tz = $ENV{TZ}; |
766 |
if ( $db_driver eq 'mysql' ) { |
767 |
# Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config. |
768 |
# this is better than modifying my.cnf (and forcing all communications to be in utf8) |
769 |
$dbh->{'mysql_enable_utf8'}=1; #enable |
770 |
$dbh->do("set NAMES 'utf8'"); |
771 |
($tz) and $dbh->do(qq(SET time_zone = "$tz")); |
772 |
} |
773 |
elsif ( $db_driver eq 'Pg' ) { |
774 |
$dbh->do( "set client_encoding = 'UTF8';" ); |
775 |
($tz) and $dbh->do(qq(SET TIME ZONE = "$tz")); |
776 |
} |
777 |
return $dbh; |
778 |
} |
729 |
} |
779 |
|
730 |
|
780 |
=head2 dbh |
731 |
=head2 dbh |