jdtoronto has asked for the wisdom of the Perl Monks concerning the following question:
I have an application where I am using 'mapping' in Class::DBI, after some help here a couple of days ago I got that working quite happily. But I need to figure out how to add a map when I add a user.
My three classes are these:
When I add a new 'AppSys::User' I want to also add a mapping in 'AppSys::MapPrUser', I have the appropriate provider id I wish to reference, but I am not sure how to write the method to add it, nor which Class it should actually appear in!package AppSys::MapPrUser; use base AppSys::DBI; __PACKAGE__->table("map_pr_usr"); __PACKAGE__->columns(Primary => qw(provider_id user_id)); __PACKAGE__->has_a(provider_id => AppSys::Provider); __PACKAGE__->has_a(user_id => AppSys::User); package AppSys::User; use base AppSys::DBI; __PACKAGE__->set_up_table("ap_uprofile"); __PACKAGE__->has_many(providers => ['AppSys::MapPrUser' => 'provider_i +d']); __PACKAGE__->has_many(appointments => 'AppSys::PrAppointments', 'useri +d'); package AppSys::Provider; use base AppSys::DBI; __PACKAGE__->set_up_table("ap_prprofile"); __PACKAGE__->has_a(defAptType => 'AppSys::ApptTypes'); __PACKAGE__->has_many(appointments => 'AppSys::PrAppointments', 'provi +derid', {sort => 'appdate'}); __PACKAGE__->has_many(users => ['AppSys::MapPrUser' => 'user_id']); __PACKAGE__->has_many(appointment_types => 'AppSys::ApptTypes', 'provi +derid');
Thanks in advance!
...john
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Class::DBI - addiing map entry when adding to one of the mapped classes.
by cees (Curate) on Feb 17, 2004 at 20:43 UTC |