# database connection from the data given in the current context, and
# returns it.
sub _new_schema {
- my $db_driver;
+
my $context = C4::Context->new();
- if ( $context->config("db_scheme") ) {
- $db_driver = $context->db_scheme2dbi( $context->config("db_scheme") );
- }
- else {
- $db_driver = "mysql";
- }
- my $db_name = $context->config("database");
- my $db_host = $context->config("hostname");
- my $db_port = $context->config("port") || '';
- my $db_user = $context->config("user");
- my $db_passwd = $context->config("pass");
- my $schema = Koha::Schema->connect(
- "DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",
- $db_user, $db_passwd );
+ # we are letting C4::Context->dbh not set the RaiseError handle attribute
+ # for now for compatbility purposes
+ my $schema = Koha::Schema->connect( sub { C4::Context->dbh }, { unsafe => 1 } );
return $schema;
}