Esteemed monks,

For some reason my foreign key related values are not being inflated when I retrieve them using Class::DBI.

I have two tables. One called as_dow which has this structure:

Field Type Null Key Default Extra -------- ----------- ------- ------ ---------- -------- id int(11) PRI 0 int_dow varchar(50)
and the second, pr_businesshours which looks like this:
Field Type Null Key Default Extra + ------------ ------------- ------- ------ ---------- ----------- +--- interval_id int(11) PRI (null) auto_increm +ent provider_id int(11) 0 + personell_id int(11) 0 + int_type int(11) 0 + int_dow varchar(50) + int_start time 00:00:00 + int_end time 00:00:00 + int_int decimal(10,0) 00
The values for int_dow in pr_businesshours are 0..6 corresponding to the days of the week. Likewise in as_dow the keys (id) are 0..6 with the corresponding abbreviated text versions of the days stored in int_dow.

In my sub-classing of Class::DBI I did this:

package AppSys::DBI; use Class::DBI::Iterator; use base 'Class::DBI::mysql'; AppSys::DBI->set_db('Main', 'DBI:mysql:appsys', '****', '****'); package AppSys::BusinessHours; use base AppSys::DBI; AppSys::BusinessHours->set_up_table("pr_businesshours"); AppSys::BusinessHours->has_a('int_dow' => 'AppSys::DOW'); package AppSys::DOW; use base AppSys::DBI; AppSys::DOW->set_up_table("as_dow");
But when I search for the records, then retrieve them the value for int_dow does not get inflated. I think I am not understanding something, here is a code fragment from my CGI::Application run_mode:
@ints = AppSys::BusinessHours->search( provider_id => $provider_id +, {order_by => 'int_dow'}); my @loh; #while ( my $day = $ints->next ) { foreach (@ints) { my $day = AppSys::BusinessHours->retrieve( $_->id ); my $hashref = { map { $_ => $day->get($_); } $day->columns }; push ( @loh, $hashref ); }
Any clues please brethren?

jdtoronto

UPDATED: The thought just occurred to me that possibly the relationship is not inflated if I use the get method?


In reply to Inflating foreign key values in Class::DBI 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.