Esteemed Monks,

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:

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');
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!

Thanks in advance!
...john

jdtoronto


In reply to Class::DBI - addiing map entry when adding to one of the mapped classes. by jdtoronto

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.