Commit | Line | Data |
ad91060a |
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 | |
0f2fd2c0 |
25 | # certain ->schema methods (source, resultset, class) have shortcuts |
26 | $c->model('Foo')->source(...); |
27 | $c->model('Foo')->resultset(...); |
28 | $c->model('Foo')->class(...); |
29 | |
30 | # For resultsets, there's an even quicker shortcut: |
31 | $c->model('Foo::Bar') |
32 | # is the same as $c->model('Foo')->resultset('Bar') |
ad91060a |
33 | |
34 | # To get the composed schema for making new connections: |
35 | my $newconn = $c->model('Foo')->composed_schema->connect(...); |
36 | |
37 | # Or the same thing via a convenience shortcut: |
38 | my $newconn = $c->model('Foo')->connect(...); |
39 | |
40 | # or, if your schema works on different storage drivers: |
41 | my $newconn = $c->model('Foo')->composed_schema->clone(); |
42 | $newconn->storage_type('::LDAP'); |
7b39f3f0 |
43 | $newconn->connection(...); |
ad91060a |
44 | |
45 | # and again, a convenience shortcut |
46 | my $newconn = $c->model('Foo')->clone(); |
47 | $newconn->storage_type('::LDAP'); |
7b39f3f0 |
48 | $newconn->connection(...); |
ad91060a |
49 | |
50 | DESCRIPTION |
7b39f3f0 |
51 | This is a Catalyst Model for DBIx::Class::Schema-based Models. See the |
52 | documentation for Catalyst::Helper::Model::DBIC::Schema and |
1aeb6e1e |
53 | Catalyst::Helper::Model::DBIC::SchemaLoader for information on |
54 | generating these Models via Helper scripts. The latter of the two will |
55 | also generated a DBIx::Class::Schema::Loader-based Schema class for you. |
ad91060a |
56 | |
57 | CONFIG PARAMETERS |
58 | schema_class |
59 | This is the classname of your DBIx::Class::Schema Schema. It needs |
60 | to be findable in @INC, but it does not need to be underneath |
0f2fd2c0 |
61 | "Catalyst::Model::". This parameter is required. |
ad91060a |
62 | |
63 | connect_info |
64 | This is an arrayref of connection parameters, which are specific to |
65 | your "storage_type". For "::DBI", which is the only supported |
66 | "storage_type" in DBIx::Class at the time of this writing, the 4 |
67 | parameters are your dsn, username, password, and connect options |
68 | hashref. |
69 | |
0f2fd2c0 |
70 | This is not required if "schema_class" already has connection |
71 | information defined in itself (which would be the case for a Schema |
72 | defined by DBIx::Class::Schema::Loader, for instance). |
73 | |
ad91060a |
74 | storage_type |
75 | Allows the use of a different "storage_type" than what is set in |
76 | your "schema_class" (which in turn defaults to "::DBI" if not set in |
b8427e0b |
77 | current DBIx::Class). Completely optional, and probably unnecessary |
78 | for most people until other storage backends become available for |
ad91060a |
79 | DBIx::Class. |
80 | |
81 | METHODS |
82 | new Instantiates the Model based on the above-documented ->config |
0f2fd2c0 |
83 | parameters. The only required parameter is "schema_class". |
84 | "connect_info" is required in the case that "schema_class" does not |
85 | already have connection information defined for it. |
ad91060a |
86 | |
87 | schema |
88 | Accessor which returns the connected schema being used by the this |
0f2fd2c0 |
89 | model. There are already direct shortcuts on the model class itself |
90 | for schema->resultset, schema->source, and schema->class. |
ad91060a |
91 | |
92 | composed_schema |
93 | Accessor which returns the composed schema, which has no connection |
94 | info, which was used in constructing the "schema" above. Useful for |
0f2fd2c0 |
95 | creating new connections based on the same schema/model. There are |
96 | direct shortcuts from the model object for composed_schema->clone |
97 | and composed_schema->connect |
ad91060a |
98 | |
99 | clone |
100 | Shortcut for ->composed_schema->clone |
101 | |
102 | connect |
103 | Shortcut for ->composed_schema->connect |
104 | |
0f2fd2c0 |
105 | source |
106 | Shortcut for ->schema->source |
107 | |
108 | class |
109 | Shortcut for ->schema->class |
110 | |
111 | resultset |
112 | Shortcut for ->schema->resultset |
113 | |
b8427e0b |
114 | storage |
115 | Provides an accessor for the connected schema's storage object. Used |
116 | often for debugging and controlling transactions. |
117 | |
ad91060a |
118 | SEE ALSO |
7b39f3f0 |
119 | General Catalyst Stuff: |
120 | |
121 | Catalyst::Manual, Catalyst::Test, Catalyst::Request, Catalyst::Response, |
122 | Catalyst::Helper, Catalyst, |
123 | |
124 | Stuff related to DBIC and this Model style: |
125 | |
126 | DBIx::Class, DBIx::Class::Schema, DBIx::Class::Schema::Loader, |
127 | Catalyst::Helper::Model::DBIC::Schema, |
1aeb6e1e |
128 | Catalyst::Helper::Model::DBIC::SchemaLoader |
ad91060a |
129 | |
130 | AUTHOR |
131 | Brandon L Black, "blblack@gmail.com" |
132 | |
133 | COPYRIGHT |
134 | This program is free software, you can redistribute it and/or modify it |
135 | under the same terms as Perl itself. |
136 | |