[Catalyst] Using C::DBI::Loader::Relationship with Model::CDBI?

Michael Reece mreece at sacbee.com
Wed Apr 6 00:20:57 CEST 2005


You may need to overload the constructor ..

use Class::DBI::Loader::Relationship;

sub new {
    my ($self, $c) = @_;
    $self = $self->NEXT::new($c);

    $self->loader->relationship( "a user has groups" );

    return $self;
}

On 4/5/05 12:55 PM, "Andy Grundman" <andy at hybridized.org> wrote:

> Since I'm not able to automatically setup my table relationships using
> Class::DBI::Loader::mysql (I think that requires InnoDB tables), I was
> looking to add on the Loader::Relationship module which lets you specify
> your relationships using english syntax.  In a non-Catalyst app,
> I can do something like this:
> 
> use Class::DBI::Loader;
> use Class::DBI::Loader::Relationship;
> my $loader = Class::DBI::Loader->new(
>  dsn => 'dbi:mysql:test',
>  namespace => 'MyApp',
> );
> $loader->relationship( "a user has groups" );
> 
> I tried to do something similar in Catalyst, but I can't figure out how
> to make the Relationship class load up properly:
> 
> package MyApp::Model::CDBI;
> use base 'Catalyst::Model::CDBI';
> 
> __PACKAGE__->config(
>  dsn => 'dbi:mysql:test',
>  additional_classes => [qw/Class::DBI::Loader::Relationship/],
> );
> __PACKAGE__->loader->relationship( "a user has groups" );
> 
> I've also tried __PACKAGE__->relationship( ... ) and use'ing the
> Relationship module at the top of the module.
> 
> Thanks,
> -Andy
> 
> 
> 
> 
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
> 

-- 
michael reece :: web engineer :: mreece at sacbee.com :: (916)321-1249





More information about the Catalyst mailing list