use Koha::Database; my $database = Koha::Database->new(); my $schema = $database->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
$schema = $database->new_schema;
Creates a new connection to the Koha database for the current context, and returns the database handle (a
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.
$my_schema = $database->new_schema; $database->set_schema($my_schema); ... $database->restore_schema;
&restore_schema work in a manner analogous to
&set_schema saves the current database handle on a stack, then sets the current database handle to
$my_schema is assumed to be a good database handle.
Restores the database handle saved by an earlier call to
None by default.
Chris Cormack, <email@example.com>