-package DBIx::Class::Loader;
+package DBIx::Class::Schema::Loader;
use strict;
use UNIVERSAL::require;
=head1 NAME
-DBIx::Class::Loader - Dynamic definition of DBIx::Class sub classes.
+DBIx::Class::Schema::Loader - Dynamic definition of a DBIx::Class::Schema
=head1 SYNOPSIS
- use DBIx::Class::Loader;
+ use DBIx::Class::Schema::Loader;
- my $loader = DBIx::Class::Loader->new(
+ my $loader = DBIx::Class::Schema::Loader->new(
dsn => "dbi:mysql:dbname",
user => "root",
password => "",
debug => 1,
);
- my $conn = $loader->get_connection($dsn, $user, $password); #
- my $conn = $loader->get_connection(); # uses same dsn as ->new();
+ my $conn = $loader->connection($dsn, $user, $password); #
+ my $conn = $loader->connection(); # uses same dsn as ->new();
use with mod_perl
use strict;
# you can use Data::Film directly
- my $film = Data::Film->retrieve($id);
-
+ my $conn = $loader->connection();
+ my $film_moniker = $loader->moniker('film');
+ my $a_film = $conn->resultset($film_moniker)->find($id);
=head1 DESCRIPTION
-DBIx::Class::Loader automate the definition of DBIx::Class sub-classes by
-scanning table schemas and setting up columns and primary keys.
-
-Class names are defined by table names and the namespace option, which is
-required.
-
- +---------+-----------+--------------+
- | table | namespace | class |
- +---------+-----------+--------------+
- | foo | Data | Data::Foo |
- | foo_bar | MyDB | MyDB::FooBar |
- +---------+-----------+--------------+
+DBIx::Class::Schema::Loader automate the definition of a
+DBIx::Class::Schema by scanning table schemas and setting up
+columns and primary keys.
-DBIx::Class::Loader supports MySQL, Postgres, SQLite and DB2. See
-L<DBIx::Class::Loader::Generic> for more, and L<DBIx::Class::Loader::Writing>
-for notes on writing your own db-specific subclass for an unsupported db.
+DBIx::Class::Schema::Loader supports MySQL, Postgres, SQLite and DB2. See
+L<DBIx::Class::Schema::Loader::Generic> for more, and
+L<DBIx::Class::Schema::Loader::Writing> for notes on writing your own
+db-specific subclass for an unsupported db.
-L<Class::DBI::Loader> and L<Class::DBI> are now obsolete, use L<DBIx::Class> and this module instead. ;)
+L<Class::DBI::Loader>, L<Class::DBI>, and L<DBIx::Class::Loader> are now
+obsolete, use L<DBIx::Class> and this module instead. ;)
=cut
Example in Synopsis above demonstrates the available arguments. For
detailed information on the arguments, see the
-L<DBIx::Class::Loader::Generic> documentation.
+L<DBIx::Class::Schema::Loader::Generic> documentation.
=cut
my $dsn = $args{dsn};
my ($driver) = $dsn =~ m/^dbi:(\w*?)(?:\((.*?)\))?:/i;
$driver = 'SQLite' if $driver eq 'SQLite2';
- my $impl = "DBIx::Class::Loader::" . $driver;
+ my $impl = "DBIx::Class::Schema::Loader::" . $driver;
$impl->require or
die qq/Couldn't require loader class "$impl", "$UNIVERSAL::require::ERROR"/;
-package DBIx::Class::Loader::DB2;
+package DBIx::Class::Schema::Loader::DB2;
use strict;
-use base 'DBIx::Class::Loader::Generic';
+use base 'DBIx::Class::Schema::Loader::Generic';
use DBI;
use Carp;
=head1 NAME
-DBIx::Class::Loader::DB2 - DBIx::Class::Loader DB2 Implementation.
+DBIx::Class::Schema::Loader::DB2 - DBIx::Class::Schema::Loader DB2 Implementation.
=head1 SYNOPSIS
- use DBIx::Class::Loader;
+ use DBIx::Schema::Class::Loader;
- # $loader is a DBIx::Class::Loader::DB2
- my $loader = DBIx::Class::Loader->new(
+ # $loader is a DBIx::Class::Schema::Loader::DB2
+ my $loader = DBIx::Class::Schema::Loader->new(
dsn => "dbi:DB2:dbname",
user => "myuser",
password => "",
schema => "MYSCHEMA",
dropschema => 0,
);
- my $class = $loader->find_class('film'); # $class => Data::Film
- my $obj = $class->retrieve(1);
=head1 DESCRIPTION
-See L<DBIx::Class::Loader>.
+See L<DBIx::Class::Schema::Loader>.
=cut
=head1 SEE ALSO
-L<DBIx::Class::Loader>
+L<DBIx::Class::Schema::Loader>
=cut
-package DBIx::Class::Loader::Generic;
+package DBIx::Class::Schema::Loader::Generic;
use strict;
use base 'DBIx::Class::Componentised';
=head1 NAME
-DBIx::Class::Loader::Generic - Generic DBIx::Class::Loader Implementation.
+DBIx::Class::Schema::Loader::Generic - Generic DBIx::Class::Schema::Loader Implementation.
=head1 SYNOPSIS
-See L<DBIx::Class::Loader>
+See L<DBIx::Class::Schema::Loader>
=head1 DESCRIPTION
=head3 new
Not intended to be called directly. This is used internally by the
-C<new()> method in L<DBIx::Class::Loader>.
+C<new()> method in L<DBIx::Class::Schema::Loader>.
=cut
TABLE_CLASSES => {},
MONIKERS => {},
}, $class;
- warn qq/\### START DBIx::Class::Loader dump ###\n/ if $self->debug;
+ warn qq/\### START DBIx::Class::Schema::Loader dump ###\n/ if $self->debug;
$self->_load_classes;
$self->_relationships if $self->{_relationships};
- warn qq/\### END DBIx::Class::Loader dump ###\n/ if $self->debug;
+ warn qq/\### END DBIx::Class::Schema::Loader dump ###\n/ if $self->debug;
$self->{_storage}->dbh->disconnect;
$self;
}
=head1 SEE ALSO
-L<DBIx::Class::Loader>
+L<DBIx::Class::Schema::Loader>
=cut
-package DBIx::Class::Loader::Pg;
+package DBIx::Class::Schema::Loader::Pg;
use strict;
-use base 'DBIx::Class::Loader::Generic';
+use base 'DBIx::Class::Schema::Loader::Generic';
use DBI;
use Carp;
=head1 NAME
-DBIx::Class::Loader::Pg - DBIx::Class::Loader Postgres Implementation.
+DBIx::Class::Schema::Loader::Pg - DBIx::Class::Schema::Loader Postgres Implementation.
=head1 SYNOPSIS
- use DBIx::Class::Loader;
+ use DBIx::Class::Schema::Loader;
- # $loader is a DBIx::Class::Loader::Pg
- my $loader = DBIx::Class::Loader->new(
+ # $loader is a DBIx::Class::Schema::Loader::Pg
+ my $loader = DBIx::Class::Schema::Loader->new(
dsn => "dbi:Pg:dbname=dbname",
user => "postgres",
password => "",
namespace => "Data",
);
- my $class = $loader->find_class('film'); # $class => Data::Film
- my $obj = $class->retrieve(1);
=head1 DESCRIPTION
-See L<DBIx::Class::Loader>.
+See L<DBIx::Class::Schema::Loader>.
=cut
=head1 SEE ALSO
-L<DBIx::Class::Loader>
+L<DBIx::Class::Schema::Loader>
=cut
-package DBIx::Class::Loader::SQLite;
+package DBIx::Class::Schema::Loader::SQLite;
use strict;
-use base 'DBIx::Class::Loader::Generic';
+use base 'DBIx::Class::Schema::Loader::Generic';
use Text::Balanced qw( extract_bracketed );
use DBI;
use Carp;
=head1 NAME
-DBIx::Class::Loader::SQLite - DBIx::Class::Loader SQLite Implementation.
+DBIx::Class::Schema::Loader::SQLite - DBIx::Class::Schema::Loader SQLite Implementation.
=head1 SYNOPSIS
- use DBIx::Class::Loader;
+ use DBIx::Class::Schema::Loader;
- # $loader is a DBIx::Class::Loader::SQLite
- my $loader = DBIx::Class::Loader->new(
+ # $loader is a DBIx::Class::Schema::Loader::SQLite
+ my $loader = DBIx::Class::Schema::Loader->new(
dsn => "dbi:SQLite:dbname=/path/to/dbfile",
namespace => "Data",
);
- my $class = $loader->find_class('film'); # $class => Data::Film
- my $obj = $class->retrieve(1);
=head1 DESCRIPTION
-See L<DBIx::Class::Loader>.
+See L<DBIx::Class::Schema::Loader>.
=cut
=head1 SEE ALSO
-L<DBIx::Class::Loader>
+L<DBIx::Schema::Class::Loader>
=cut
-package DBIx::Class::Loader::Writing;
+package DBIx::Class::Schema::Loader::Writing;
# Empty. POD only.
=head1 NAME
-DBIx::Class::Loader::Writing - Loader subclass writing guide
+DBIx::Class::Schema::Loader::Writing - Loader subclass writing guide
=head1 SYNOPSIS
- package DBIx::Class::Loader::Foo;
+ package DBIx::Class::Schema::Loader::Foo;
# THIS IS JUST A TEMPLATE TO GET YOU STARTED.
use strict;
- use base 'DBIx::Class::Loader::Generic';
+ use base 'DBIx::Class::Schema::Loader::Generic';
use DBI;
use Carp;
-package DBIx::Class::Loader::mysql;
+package DBIx::Class::Schema::Loader::mysql;
use strict;
-use base 'DBIx::Class::Loader::Generic';
+use base 'DBIx::Class::Schema::Loader::Generic';
use DBI;
use Carp;
=head1 NAME
-DBIx::Class::Loader::mysql - DBIx::Class::Loader mysql Implementation.
+DBIx::Class::Schema::Loader::mysql - DBIx::Schema::Class::Loader mysql Implementation.
=head1 SYNOPSIS
- use DBIx::Class::Loader;
+ use DBIx::Class::Schema::Loader;
- # $loader is a DBIx::Class::Loader::mysql
- my $loader = DBIx::Class::Loader->new(
+ # $loader is a DBIx::Class::Schema::Loader::mysql
+ my $loader = DBIx::Class::Schema::Loader->new(
dsn => "dbi:mysql:dbname",
user => "root",
password => "",
namespace => "Data",
);
- my $class = $loader->find_class('film'); # $class => Data::Film
- my $obj = $class->retrieve(1);
=head1 DESCRIPTION
-See L<DBIx::Class::Loader>.
+See L<DBIx::Class::Schema::Loader>.
=cut
=head1 SEE ALSO
-L<DBIx::Class::Loader>
+L<DBIx::Class::Schema::Loader>
=cut
use strict;
use Test::More;
-use DBIx::Class::Loader;
+use DBIx::Class::Schema::Loader;
use DBI;
sub new {
my $debug = ($self->{verbose} > 1) ? 1 : 0;
- my $loader = DBIx::Class::Loader->new(
+ my $loader = DBIx::Class::Schema::Loader->new(
dsn => $self->{dsn},
user => $self->{user},
password => $self->{password},