SchemaView-Plus
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/DBIx/SystemCatalog.pm view on Meta::CPAN
$dbh->disconnect;
=head1 DESCRIPTION
This module can access to system catalog of database through DBI(3) interface.
Basic methods access to objects through standard DBI(3) interface
(call C<tables()> for list of objects and C<selectall_arrayref()> with basic
SQL to get structure of objects).
Constructor looks for specific module implemented database interface for
used DBD driver (obtained from DBI(3)). These module can add faster and better
functions such as relationships or types of objects.
=head1 CONSTANTS
=head2 Type of object
=over 4
=item SC_TYPE_UNKNOWN
=cut
sub SC_TYPE_UNKNOWN () { return 0; }
=item SC_TYPE_TABLE
=cut
sub SC_TYPE_TABLE () { return 1; }
=item SC_TYPE_VIEW
=back
=cut
sub SC_TYPE_VIEW () { return 2; }
=head1 THE DBIx::SystemCatalog CLASS
=head2 new (DBI)
Constructor create instance of this class and bind DBI(3) connection.
Then obtain used driver name from DBI(3) class and look for descendant
of this class for this driver (e.g. C<DBIx::SystemCatalog::Oracle> module
for C<Oracle> driver). If success, return instance of this more specific class,
otherwise return itself.
You must passed connected DBI(3) instance as first argument to constructor
and you can't disconnect that instance while you use this instance of
DBIx::SystemCatalog.
$catalog = new DBIx::SystemCatalog $dbh
=cut
sub new {
my $class = shift;
my $dbi = shift;
my $obj = bless { dbi => $dbi, class => $class, schema => '' },$class;
$obj->{Driver} = $obj->{dbi}->{Driver}->{Name};
# Only base class can dispatch to more specific class
if ($class eq 'DBIx::SystemCatalog') {
my $driver_name = 'DBIx::SystemCatalog::'.$obj->{Driver};
eval "package DBIx::SystemCatalog::_safe; require $driver_name";
unless ($@) { # found specific driver
$driver_name->import();
return $driver_name->new($dbi,@_);
}
}
# Hmm, we are specific class or specific class not found
return undef unless $obj->init(@_);
return $obj;
}
=head2 init
Because C<new()> is quite complicated, descendant inherits this C<new()>
constructor and redefine C<init()> constructor which is called from C<new()>.
C<init()> gets all arguments from C<new()> with one exception - instead of
name of class this constructor get instance of object.
Constructor must return true value to make successful of creating instance
of object. In this base class is C<init()> abstract, always true.
This method isn't called directly from user.
=cut
sub init { 1; }
=head2 schemas
Method must return list of schemas from database. In this base class method
always return empty list, because standard DBI(3) method can't get list of
schemas.
my @schemas = $catalog->schemas()
=cut
sub schemas {
return ();
}
=head2 schema (NAME)
Method set current schema name. Other methods work only with this schema.
Because working with one schema is typical work, all methods in specific
class need this schema name. Method can set schema (descendant need not
redefine it).
$catalog->schema('IS')
=cut
sub schema {
view all matches for this distributionview release on metacpan - search on metacpan
( run in 4.893 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-9f2165ba459b )