<<

NAME

Koha::Database

SYNOPSIS

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

FUNCTIONS

schema

    $schema = $database->schema;

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. If you need a second database handle, use &new_schema and possibly &set_schema.

new_schema

  $schema = $database->new_schema;

Creates a new connection to the Koha database for the current context, and returns the database handle (a DBI::db object).

The handle is not saved anywhere: this method is strictly a convenience function; the point is that it knows which database to connect to so that the caller doesn't have to know.

set_schema

  $my_schema = $database->new_schema;
  $database->set_schema($my_schema);
  ...
  $database->restore_schema;

&set_schema and &restore_schema work in a manner analogous to &set_context and &restore_context.

&set_schema saves the current database handle on a stack, then sets the current database handle to $my_schema.

$my_schema is assumed to be a good database handle.

restore_schema

  $database->restore_schema;

Restores the database handle saved by an earlier call to $database->set_schema.

get_schema_cached

flush_schema_cache

EXPORT

None by default.

AUTHOR

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

<<