Lines 788-803
sub _new_Zconn {
Link Here
|
788 |
# Internal helper function (not a method!). This creates a new |
788 |
# Internal helper function (not a method!). This creates a new |
789 |
# database connection from the data given in the current context, and |
789 |
# database connection from the data given in the current context, and |
790 |
# returns it. |
790 |
# returns it. |
|
|
791 |
our $db_driver = 'mysql'; |
791 |
sub _new_dbh |
792 |
sub _new_dbh |
792 |
{ |
793 |
{ |
793 |
|
794 |
|
794 |
## $context |
795 |
## $context |
795 |
## correct name for db_schme |
796 |
## correct name for db_schme |
796 |
my $db_driver; |
|
|
797 |
if ($context->config("db_scheme")){ |
797 |
if ($context->config("db_scheme")){ |
798 |
$db_driver=db_scheme2dbi($context->config("db_scheme")); |
798 |
$db_driver=db_scheme2dbi($context->config("db_scheme")); |
799 |
}else{ |
|
|
800 |
$db_driver="mysql"; |
801 |
} |
799 |
} |
802 |
|
800 |
|
803 |
my $db_name = $context->config("database"); |
801 |
my $db_name = $context->config("database"); |
Lines 823-828
sub _new_dbh
Link Here
|
823 |
$dbh->{RaiseError} = 0; |
821 |
$dbh->{RaiseError} = 0; |
824 |
} |
822 |
} |
825 |
|
823 |
|
|
|
824 |
if ( $db_driver eq 'mysql' ) { |
825 |
$dbh->{mysql_auto_reconnect} = 1; |
826 |
} |
827 |
|
826 |
my $tz = $ENV{TZ}; |
828 |
my $tz = $ENV{TZ}; |
827 |
if ( $db_driver eq 'mysql' ) { |
829 |
if ( $db_driver eq 'mysql' ) { |
828 |
# Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config. |
830 |
# Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config. |
Lines 857-866
possibly C<&set_dbh>.
Link Here
|
857 |
sub dbh |
859 |
sub dbh |
858 |
{ |
860 |
{ |
859 |
my $self = shift; |
861 |
my $self = shift; |
|
|
862 |
my $params = shift; |
860 |
my $sth; |
863 |
my $sth; |
861 |
|
864 |
|
862 |
if (defined($context->{"dbh"}) && $context->{"dbh"}->ping()) { |
865 |
unless ( $params->{new} ) { |
863 |
return $context->{"dbh"}; |
866 |
if ( defined $db_driver && $db_driver eq 'mysql' && $context->{"dbh"} ) { |
|
|
867 |
return $context->{"dbh"}; |
868 |
} elsif ( defined $db_driver && defined($context->{"dbh"}) && $context->{"dbh"}->ping()) { |
869 |
return $context->{"dbh"}; |
870 |
} |
864 |
} |
871 |
} |
865 |
|
872 |
|
866 |
# No database handle or it died . Create one. |
873 |
# No database handle or it died . Create one. |