<<

NAME

Koha::Database

SYNOPSIS

  use Koha::Database;
  my $schema = Koha::Database->schema();

FUNCTIONS

new

    $schema = Koha::Database->new->schema;

    FIXME: It is useless to have a Koha::Database object since all methods
    below act as class methods
    Koha::Database->new->schema is exactly the same as Koha::Database->schema
    We should use Koha::Database->schema everywhere and remove the `new` method

dbh

    Returns a database handler without loading the DBIx::Class schema.

schema

    $schema = Koha::Database->schema;
    $schema = Koha::Database->schema({ new => 1 });

Returns a database handle connected to the Koha database for the current context. If no connection has yet been made, this method creates one, and connects to the database.

This database handle is cached for future use: if you call $database->schema twice, you will get the same handle both times.

db_scheme2dbi

    my $dbd_driver_name = Koha::Database::db_scheme2dbi($scheme);

This routines translates a database type to part of the name of the appropriate DBD driver to use when establishing a new database connection. It recognizes 'mysql' and 'Pg'; if any other scheme is supplied it defaults to 'mysql'.

generate_dsn

    my $dsn = Koha::Database::generate_dsn($config);

Returns a data source name (DSN) for a database connection from the config instance.

EXPORT

None by default.

AUTHOR

Chris Cormack, <chrisc@catalyst.net.nz>

<<