[Catalyst] [ANNOUNCEME] Catalyst::Model::DBIC::Plain

Danijel Milicevic Danijel.Milicevic at rawmode.org
Tue Aug 9 20:02:28 CEST 2005


Hey lists,

since Matt released DBIC 0.01 last night it kinda made sense to release
C::M::DBIC::Plain as well for the Catalyst users to play with. Just to
fill this announcement up a little bit, here is the pod:

=head1 NAME

Catalyst::Model::DBIC::Plain - DBIC Model Class

=head1 SYNOPSIS

    # lib/MyApp/Model/DBIC.pm
    package MyApp::Model::DBIC;
    use base 'Catalyst::Model::DBIC::Plain';

    my @conn_info = ( $dsn, $username, $password, \%dbi_attributes );

    __PACKAGE__->load_classes;
    __PACKAGE__->compose_connection(__PACKAGE__, @conn_info);

    1;

    # lib/MyApp/Model/DBIC/User.pm
    package MyApp::Model::DBIC::User;
    use base 'DBIx::Class::Core';

    __PACKAGE__->table('user');
    __PACKAGE__->add_columns(qw/id username password email clearance/);
    __PACKAGE__->set_primary_key('id');
    __PACKAGE__->add_relationship(
        clearance => 'MyApp::Model::DBIC::Clearance',
        { 'foreign.id => 'self.clearance' }
    );

    # lib/MyApp/Controller/MyController.pm
    $c->comp('DBIC')->class('user')->search(...);

    # or
    MyApp::Model::DBIC::User->search(...);

=head1 DESCRIPTION

This is the C<DBIx::Class> model class for Catalyst. Whilst it allows
you to
use DBIC as your model in Catalyst, it does not make your tables classes
Catalyst-specific, so you can still use them in a non-Catalyst context.


Thanks to the helper script you can setup your model as easy as:
$ script/myapp_create.pl model DBIC DBIC::Plain dsn user pass

Enjoy,
Danijel Milicevic




More information about the Catalyst mailing list