View | Details | Raw Unified | Return to bug 15350
Collapse All | Expand All

(-)a/Koha/Database.pm (-5 / +10 lines)
Lines 35-54 Koha::Database Link Here
35
use Modern::Perl;
35
use Modern::Perl;
36
use Carp;
36
use Carp;
37
use C4::Context;
37
use C4::Context;
38
use Koha::Schema;
38
use base qw(Class::Accessor);
39
use base qw(Class::Accessor);
39
40
40
use vars qw($database);
41
use vars qw($database);
41
42
42
__PACKAGE__->mk_accessors(qw( ));
43
__PACKAGE__->mk_accessors(qw( ));
43
44
45
BEGIN {
46
    # Initialize the base schema object (just loads the schema classes)
47
    $database->{base_schema} = Koha::Schema->clone;
48
}
49
44
# _new_schema
50
# _new_schema
45
# Internal helper function (not a method!). This creates a new
51
# Internal helper function (not a method!). This creates a new
46
# database connection from the data given in the current context, and
52
# database connection from the data given in the current context, and
47
# returns it.
53
# returns it.
48
sub _new_schema {
54
sub _new_schema {
49
50
    require Koha::Schema;
51
52
    my $context = C4::Context->new();
55
    my $context = C4::Context->new();
53
56
54
    my $db_driver = $context->{db_driver};
57
    my $db_driver = $context->{db_driver};
Lines 70-76 sub _new_schema { Link Here
70
        $encoding_query = "set client_encoding = 'UTF8';";
73
        $encoding_query = "set client_encoding = 'UTF8';";
71
        $tz_query = qq(SET TIME ZONE = "$tz") if $tz;
74
        $tz_query = qq(SET TIME ZONE = "$tz") if $tz;
72
    }
75
    }
73
    my $schema = Koha::Schema->connect(
76
77
    # This creates a new copy of the schema with its own database handle but with all the schema
78
    # classes already loaded.
79
    my $schema = $database->{base_schema}->connect(
74
        {
80
        {
75
            dsn => "dbi:$db_driver:database=$db_name;host=$db_host;port=$db_port",
81
            dsn => "dbi:$db_driver:database=$db_name;host=$db_host;port=$db_port",
76
            user => $db_user,
82
            user => $db_user,
77
- 

Return to bug 15350