X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader.pm;fp=lib%2FDBIx%2FClass%2FLoader.pm;h=75318cf1c8cf08c8bcfce9641966b1aed261e602;hb=18fca96ada05368ead5bb38b5c868e9c4d5c0c07;hp=7c7868eb4e0f5beaf8c0a6a5d79f08deb34fa7fb;hpb=af6c266584e3842998e4c2af0c15d82a089238f4;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm similarity index 62% rename from lib/DBIx/Class/Loader.pm rename to lib/DBIx/Class/Schema/Loader.pm index 7c7868e..75318cf 100644 --- a/lib/DBIx/Class/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -1,4 +1,4 @@ -package DBIx::Class::Loader; +package DBIx::Class::Schema::Loader; use strict; use UNIVERSAL::require; @@ -7,13 +7,13 @@ our $VERSION = '0.01'; =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 => "", @@ -28,8 +28,8 @@ DBIx::Class::Loader - Dynamic definition of DBIx::Class sub classes. 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 @@ -49,29 +49,23 @@ in your web application. 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 for more, and L -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 for more, and +L for notes on writing your own +db-specific subclass for an unsupported db. -L and L are now obsolete, use L and this module instead. ;) +L, L, and L are now +obsolete, use L and this module instead. ;) =cut @@ -81,7 +75,7 @@ L and L are now obsolete, use L and Example in Synopsis above demonstrates the available arguments. For detailed information on the arguments, see the -L documentation. +L documentation. =cut @@ -97,7 +91,7 @@ sub new { 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"/;