Lines 45-65
__PACKAGE__->mk_accessors(qw( ));
Link Here
|
45 |
# database connection from the data given in the current context, and |
45 |
# database connection from the data given in the current context, and |
46 |
# returns it. |
46 |
# returns it. |
47 |
sub _new_schema { |
47 |
sub _new_schema { |
48 |
my $context = C4::Context->new(); |
48 |
my $schema = Koha::Schema->connect( sub { C4::Context->dbh } ); |
49 |
my $db_driver = C4::Context::db_scheme2dbi($context->config("db_scheme")); |
|
|
50 |
|
51 |
my $db_name = $context->config("database"); |
52 |
my $db_host = $context->config("hostname"); |
53 |
my $db_port = $context->config("port") || ''; |
54 |
my $db_user = $context->config("user"); |
55 |
my $db_passwd = $context->config("pass"); |
56 |
|
57 |
my $db_opts = ($db_driver eq 'mysql') ? { mysql_enable_utf8 => 1 } : |
58 |
($db_driver eq 'Pg') ? { pg_enable_utf8 => 1 } : |
59 |
{ }; |
60 |
my $schema = Koha::Schema->connect( |
61 |
"DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port", |
62 |
$db_user, $db_passwd, $db_opts ); |
63 |
return $schema; |
49 |
return $schema; |
64 |
} |
50 |
} |
65 |
|
51 |
|