Commit | Line | Data |
8a6b44ef |
1 | NAME |
2 | DBIx::Class::Schema::Loader - Dynamic definition of a |
3 | DBIx::Class::Schema |
4 | |
5 | SYNOPSIS |
6 | package My::Schema; |
7 | use base qw/DBIx::Class::Schema::Loader/; |
8 | |
9 | __PACKAGE__->load_from_connection( |
10 | dsn => "dbi:mysql:dbname", |
11 | user => "root", |
12 | password => "", |
13 | additional_classes => [qw/DBIx::Class::Foo/], |
14 | additional_base_classes => [qw/My::Stuff/], |
15 | left_base_classes => [qw/DBIx::Class::Bar/], |
16 | constraint => '^foo.*', |
17 | relationships => 1, |
18 | options => { AutoCommit => 1 }, |
19 | inflect => { child => 'children' }, |
20 | debug => 1, |
21 | ); |
22 | |
23 | # in seperate application code ... |
24 | |
25 | use My::Schema; |
26 | |
27 | my $schema1 = My::Schema->connect( $dsn, $user, $password, $attrs); |
28 | # -or- |
29 | my $schema1 = "My::Schema"; |
30 | # ^^ defaults to dsn/user/pass from load_from_connection() |
31 | |
32 | # Get a list of the original (database) names of the tables that |
33 | # were loaded |
34 | my @tables = $schema1->loader->tables; |
35 | |
36 | # Get a hashref of table_name => 'TableName' table-to-moniker |
37 | # mappings. |
38 | my $monikers = $schema1->loader->monikers; |
39 | |
40 | # Get a hashref of table_name => 'My::Schema::TableName' |
41 | # table-to-classname mappings. |
42 | my $classes = $schema1->loader->classes; |
43 | |
457eb8a6 |
44 | # Use the schema as per normal for DBIx::Class::Schema |
8a6b44ef |
45 | my $rs = $schema1->resultset($monikers->{table_table})->search(...); |
46 | |
47 | DESCRIPTION |
457eb8a6 |
48 | THIS IS A DEVELOPMENT RELEASE. This is 0.01xxx, the first public |
49 | releases. Expect things to be broken in various ways. Expect the entire |
aec93e93 |
50 | design to be fatally flawed. Expect the interfaces to change if it |
51 | becomes neccessary. It's mostly here for people to poke at it and find |
52 | the flaws in it. 0.02 will hopefully have some sanity when we get there. |
53 | |
8a6b44ef |
54 | DBIx::Class::Schema::Loader automates the definition of a |
55 | DBIx::Class::Schema by scanning table schemas and setting up columns and |
56 | primary keys. |
57 | |
58 | DBIx::Class::Schema::Loader supports MySQL, Postgres, SQLite and DB2. |
59 | See DBIx::Class::Schema::Loader::Generic for more, and |
60 | DBIx::Class::Schema::Loader::Writing for notes on writing your own |
61 | db-specific subclass for an unsupported db. |
62 | |
457eb8a6 |
63 | This module requires DBIx::Class 0.05 or later, and obsoletes |
64 | DBIx::Class::Loader for DBIx::Class version 0.05 and later. |
8a6b44ef |
65 | |
66 | METHODS |
67 | load_from_connection |
68 | Example in Synopsis above demonstrates the available arguments. For |
69 | detailed information on the arguments, see the |
70 | DBIx::Class::Schema::Loader::Generic documentation. |
71 | |
457eb8a6 |
72 | loader |
73 | This is an accessor in the generated Schema class for accessing the |
74 | DBIx::Class::Schema::Loader::Generic -based loader object that was used |
75 | during construction. See the DBIx::Class::Schema::Loader::Generic docs |
76 | for more information on the available loader methods there. |
77 | |
8a6b44ef |
78 | AUTHOR |
f654c972 |
79 | Brandon Black, "blblack@gmail.com" |
8a6b44ef |
80 | |
81 | Based on DBIx::Class::Loader by Sebastian Riedel |
82 | |
83 | Based upon the work of IKEBE Tomohiro |
84 | |
85 | THANK YOU |
86 | Adam Anderson, Andy Grundman, Autrijus Tang, Dan Kubb, David Naughton, |
87 | Randal Schwartz, Simon Flack and all the others who've helped. |
88 | |
89 | LICENSE |
90 | This library is free software; you can redistribute it and/or modify it |
91 | under the same terms as Perl itself. |
92 | |
93 | SEE ALSO |
94 | DBIx::Class |
95 | |