NAME

DBIx::QuickORM::ORM - Binds a schema to a database for DBIx::QuickORM.

DESCRIPTION

An ORM object pairs a database definition with a schema (or autofill) and owns the primary connection to that database. It is the entry point callers use to obtain a connection or a query handle; the connection is created lazily and reused.

SYNOPSIS

my $orm = DBIx::QuickORM::ORM->new(
    db       => $db,
    schema   => $schema,
);

my $con    = $orm->connection;
my $handle = $orm->handle('users');

ATTRIBUTES

name

The name of this ORM.

db

The DBIx::QuickORM::DB definition. Settable once via db.

schema

The schema object. Either this or autofill is required.

autofill

When true, missing schema metadata is introspected from the live database.

created
compiled

Provenance metadata describing where this ORM came from.

default_handle_class

Optional default handle class passed through to new connections.

row_manager

Optional row manager class (or instance) passed through to new connections as their manager. When unset the connection uses its own default (DBIx::QuickORM::RowManager::Cached).

connection

The active connection, created lazily and cached here.

PUBLIC METHODS

$orm->init

Object construction hook invoked by Object::HashBase. Validates that a schema or autofill was provided. Not called directly.

$db = $orm->db
$orm->db($db)

Gets the database definition, or sets it once. Croaks on a second set or when fetched before being set.

$con = $orm->connect

Builds and returns a new DBIx::QuickORM::Connection for this ORM. Croaks when no database has been set.

$con = $orm->connection

Returns the active connection, creating it via connect on first use.

$orm->disconnect

Drops the cached connection.

$con = $orm->reconnect

Drops the cached connection and returns a fresh one.

$handle = $orm->handle(...)

Delegates to the active connection's handle.

SOURCE

The source code repository for DBIx::QuickORM can be found at https://github.com/exodist/DBIx-QuickORM.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See https://dev.perl.org/licenses/