| 1 | package Catalyst::Model::DBIC::Plain; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use base qw/Catalyst::Model DBIx::Class::Schema/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use NEXT; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | our $VERSION = '0.02'; | |
| 8 | |||
| 9 | =head1 NAME | ||
| 10 | |||
| 11 | Catalyst::Model::DBIC::Plain - DBIC Model Class | ||
| 12 | |||
| 13 | =head1 SYNOPSIS | ||
| 14 | |||
| 15 | # lib/MyApp/Model/DBIC.pm | ||
| 16 | package MyApp::Model::DBIC; | ||
| 17 | use base 'Catalyst::Model::DBIC::Plain'; | ||
| 18 | |||
| 19 | my @conn_info = ( $dsn, $username, $password, \%dbi_attributes ); | ||
| 20 | |||
| 21 | __PACKAGE__->load_classes; | ||
| 22 | __PACKAGE__->compose_connection(__PACKAGE__, @conn_info); | ||
| 23 | |||
| 24 | 1; | ||
| 25 | |||
| 26 | # lib/MyApp/Model/DBIC/User.pm | ||
| 27 | package MyApp::Model::DBIC::User; | ||
| 28 | use base 'DBIx::Class::Core'; | ||
| 29 | |||
| 30 | __PACKAGE__->table('user'); | ||
| 31 | __PACKAGE__->add_columns(qw/id username password email clearance/); | ||
| 32 | __PACKAGE__->set_primary_key('id'); | ||
| 33 | __PACKAGE__->add_relationship( | ||
| 34 | clearance => 'MyApp::Model::DBIC::Clearance', | ||
| 35 | { 'foreign.id => 'self.clearance' } | ||
| 36 | ); | ||
| 37 | |||
| 38 | # lib/MyApp/Controller/MyController.pm | ||
| 39 | $c->comp('DBIC')->class('user')->search(...); | ||
| 40 | |||
| 41 | # or | ||
| 42 | MyApp::Model::DBIC::User->search(...); | ||
| 43 | |||
| 44 | =head1 DESCRIPTION | ||
| 45 | |||
| 46 | This is the C<DBIx::Class> model class for Catalyst. Whilst it allows you to | ||
| 47 | use DBIC as your model in Catalyst, it does not make your tables classes | ||
| 48 | Catalyst-specific, so you can still use them in a non-Catalyst context. | ||
| 49 | |||
| 50 | =head2 new | ||
| 51 | |||
| 52 | Catalystifies DBIx::Class and makes the model model class a component. | ||
| 53 | |||
| 54 | =cut | ||
| 55 | |||
| 56 | 0 | ▶ | sub new { |
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 57 | 0 | my ( $self, $c ) = @_; | |
| 58 | 0 | $self = $self->NEXT::new($c); | |
| 59 | |||
| 60 | 0 | return $self; | |
| 61 | } | ||
| 62 | |||
| 63 | =head1 SEE ALSO | ||
| 64 | |||
| 65 | L<Catalyst>, L<DBIx::Class> | ||
| 66 | |||
| 67 | =head1 TODO | ||
| 68 | |||
| 69 | Write real tests. | ||
| 70 | |||
| 71 | =head1 AUTHOR | ||
| 72 | |||
| 73 | Danijel Milicevic, C<info@danijel.de> | ||
| 74 | |||
| 75 | =head1 THANK YOU | ||
| 76 | |||
| 77 | Dan Kubb, Matt S. Trout | ||
| 78 | |||
| 79 | =head1 COPYRIGHT | ||
| 80 | |||
| 81 | This program is free software, you can redistribute it and/or modify it | ||
| 82 | under the same terms as Perl itself. | ||
| 83 | |||
| 84 | =cut | ||
| 85 | |||
| 86 | 1 | 1; | |