internal package Foswiki::DBI::Database abstract class for any type of database connecting to foswiki
ClassMethod new() Foswiki::DBI::Database::MariaDB.
Subclasses need to specify the actual DBD driver to connect to the database.
ObjectMethod getClassName() → $string MariaDB
ObjectMethod applySchema($schema) Applies the Schema to the connected database. this is called only once when the database is connected. note that the schema must test for existing tables and indexes on its own.
ObjectMethod schemaVersion($type, $version) → $version getter/setter for the schema version meta data
ObjectMethod handler() → $dbh Returns the DBD handler that this class is delegating all work to
ObjectMethod connect() Connects to the database if not already done so and returns a DBI::db handler. this method is called automatically when the db handler is established
ObjectMethod finish() Foswikik::DBI::finish() to finalize the database connection
and close any open sockets.
ObjectMethod eachRow($tableName, %params) → $iterator Foswiki::Iterator::DBIterator
for the given parameters. This is a convenience wrapper for
my $it = Foswiki::Iterator::DBIterator->new($dbh, $stm);The statement handler is created based on the parameters provided. The
%params parameter is a hash with the following values:
$tableName are optional.
Example:
my $it = Foswiki::DBI::getDB->eachRow("SomeTable",
count => "*"
firstName => "Michael"
);
while ($it->hasNext) {
my $row = $it->next();
my $firstName = $row->{firstName};
my $middleName = $row->{middleName};
my $lastName = $row->{lastName};
my $count = $row->{count};
...
}