initial checkin
[catagits/Catalyst-Model-DBIC-Schema.git] / README
1 NAME
2     Catalyst::Model::DBIC::Schema - DBIx::Class::Schema Model Class
3
4 SYNOPSIS
5         package MyApp::Model::Foo;
6         use strict;
7         use base 'Catalyst::Model::DBIC::Schema';
8
9         __PACKAGE__->config(
10             schema_class => 'Foo::SchemaClass',
11             connect_info => [ 'dbi:Pg:dbname=foodb',
12                               'postgres',
13                               '',
14                               { AutoCommit => 1 },
15                             ],
16         );
17
18         1;
19
20         # In controller code:
21
22         # ->schema To access schema methods:
23         $c->model('Foo')->schema->source(...);
24
25         # Shortcut to the schema resultset monikers for ->search et al:
26         $c->model('Foo::Bar')->search(...);
27         # is the same as $c->model('Foo')->schema->resultset('Bar')->search(...);
28
29         # To get the composed schema for making new connections:
30         my $newconn = $c->model('Foo')->composed_schema->connect(...);
31
32         # Or the same thing via a convenience shortcut:
33         my $newconn = $c->model('Foo')->connect(...);
34
35         # or, if your schema works on different storage drivers:
36         my $newconn = $c->model('Foo')->composed_schema->clone();
37         $newconn->storage_type('::LDAP');
38         $newconn->connect(...);
39
40         # and again, a convenience shortcut
41         my $newconn = $c->model('Foo')->clone();
42         $newconn->storage_type('::LDAP');
43         $newconn->connect(...);
44
45 DESCRIPTION
46     This is a Catalyst Model for DBIx::Class::Schema-based Models.
47
48 CONFIG PARAMETERS
49     schema_class
50         This is the classname of your DBIx::Class::Schema Schema. It needs
51         to be findable in @INC, but it does not need to be underneath
52         "Catalyst::Model::".
53
54     connect_info
55         This is an arrayref of connection parameters, which are specific to
56         your "storage_type". For "::DBI", which is the only supported
57         "storage_type" in DBIx::Class at the time of this writing, the 4
58         parameters are your dsn, username, password, and connect options
59         hashref.
60
61     storage_type
62         Allows the use of a different "storage_type" than what is set in
63         your "schema_class" (which in turn defaults to "::DBI" if not set in
64         current DBIx::Class). Completely optional, and probably unneccesary
65         for most people, until other storage backends become available for
66         DBIx::Class.
67
68 METHODS
69     new Instantiates the Model based on the above-documented ->config
70         parameters.
71
72     schema
73         Accessor which returns the connected schema being used by the this
74         model.
75
76     composed_schema
77         Accessor which returns the composed schema, which has no connection
78         info, which was used in constructing the "schema" above. Useful for
79         creating new connections based on the same schema/model.
80
81     clone
82         Shortcut for ->composed_schema->clone
83
84     connect
85         Shortcut for ->composed_schema->connect
86
87 SEE ALSO
88     Catalyst, DBIx::Class, DBIx::Class::Schema, DBIx::Class::Schema::Loader
89
90 AUTHOR
91     Brandon L Black, "blblack@gmail.com"
92
93 COPYRIGHT
94     This program is free software, you can redistribute it and/or modify it
95     under the same terms as Perl itself.
96