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

Andy Grundman andy at hybridized.org
Tue Apr 5 22:55:08 CEST 2005


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






More information about the Catalyst mailing list