[Catalyst] Using C::DBI::Loader::Relationship with Model::CDBI?
Sebastian Riedel
sri at oook.de
Tue Apr 5 23:18:41 CEST 2005
Am 05.04.2005 um 22:55 schrieb Andy Grundman:
> 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
try
use NEXT;
sub new {
my $class = shift;
my $self = $class->NEXT::new(@_);
$self->loader->relationship(...);
return $self;
}
--
sebastian
More information about the Catalyst
mailing list