PerlDoc

See PublishedAPI for packages intended to be used by Plugin and Contrib authors, or browse all packages.
See also Developing plugins, Developer's Bible, Technical Overview


Parent package: Foswiki
Child packages:
  • Foswiki::DBI::Database - abstract class for any type of database connecting to foswiki
  • Foswiki::DBI::Schema - A schema is used to define tables and indexes in an SQL database. Plugins may define a schema for their own needs by subclassing this class. In general a plugin must define a schema class for each database vendor it desires to support, such as SQLite, MariaDB, Oracle etc.

internal package Foswiki::DBI

Interface for Foswiki DBI developers

StaticMethod getDB() → $database

Creates a database connection to the configured implementation, connects to it and loads the base schema.

StaticMethod loadSchema($schemaBase) → $database

Loads a database schema and returns the db. The $schemaBase is the base perl class of the caller. The real database schema being loaded resides in a sub class of the $schemaBase according to the database implementation of the system.

For example a MyPlugin must provide the following classes to support SQLite and MariaDB:

Foswiki::Plugins::MyPlugin::Schema
Foswiki::Plugins::MyPlugin::Schema::MariaDB
Foswiki::Plugins::MyPlugin::Schema::SQLite

The schema is then called using:

my $db = Foswiki::DBI::loadSchema("Foswiki::Plugins::MyPlugin::Schema");

Given MariaDB is the current database implementation, it actually loads the schema Foswiki::Plugins::MyPlugin::Schema::MariaDB and returns a singleton database object of type Foswiki::DBI::Database::MariaDB. This singleton object is shared among all subsystems connecting to the database.

StaticMethod finish()

Close any database connection being made during the session

Topic revision: r1 - 06 Aug 2023, UnknownUser
This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback