Hi folks,
I'm not getting it with foreign keys in DBIC. For example, table users
has a column called location_id, which pulls the location from the
locations table like so:
select u.user, l.location from users u, locations l where u.location_id
= l.location_id
A location has many users, so in DB::Location :
__PACKAGE__->has_many(users => 'DB::User', 'location_id');
No has_many/belongs_to mappings specified in DB::Users.
Then, in a method in MyApp::Controller::Users :
$c->stash->{user} = $c->model('DB::User')->find($id);
$c->stash->{template} = 'users/view.tt2';
But the rendered view just shows location_id, not location. I obviously
don't quite get it and have missed something here. Do I have to manually
map location_id to location in either M, V or C?
Then I read in an article called 'Catalyst vs Rails vs Django Cook off'
that "Catalyst's DBIC ORM supports multi-column primary keys and can do
relationship mapping just by reading the schema! You don't even have to
bother writing any has_many belongs_to definitions!" Exactly what I
would like to do (like CDBI::Loader::Relationship? eg "a brewery
produces beers"), but how so with DBIC?
--
Richard Jones
Leeds, UK
mailto:[EMAIL PROTECTED]
_______________________________________________
List: [email protected]
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/