in reply to Re: Class::DBI has_many
in thread Class::DBI has_many


HI,

I read the mapping docs, and I just can't get it to work. An example pertaining to the above scenarion would be really helpful!
Thanks
--
arc_of_descent

Replies are listed 'Best First'.
Re: Re: Re: Class::DBI has_many
by PodMaster (Abbot) on Dec 29, 2003 at 13:57 UTC
    I read the mapping docs, and I just can't get it to work. An example pertaining to the above scenarion would be really helpful!
    What did you try? I'm lazy, and I don't like to type.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.


      Fine. I understand.
      Anyways.. this is what I tried

      Page.pm
      __PACKAGE__->has_many(columns => [ 'Page_column' => 'column_id' ]);


      Page_column.pm
      __PACKAGE__->has_many(columns => 'Column');


      Column.pm
      __PACKAGE->has_a(column_id => 'Column');

      I know there is no free service available here, but I very much appreciate any help available. :-)
      --
      arc_of_descent

        You are close. Try this instead:
        package Page; __PACKAGE__->has_many(columns => 'Column'); package Page_column; __PACKAGE__->has_a(page_id => 'Page'); __PACKAGE__->has_a(column_id => 'Column'); package Column; __PACKAGE__->has_many(pages => 'Page');
        And if your immediate question is "Why can columns have multiple pages", then you need to go back to your 1NF 1:N design, like kal suggested. Your second example is what i call a cross table, and the tables on the ends are the "many" relationships.

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)
        
        I believe that should be  __PACKAGE__->has_many(columns => [ 'Page_column' => 'columns' ]); in Page.pm.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.

      I'm lazy, and I don't like to type.
      Phht. If you were really lazy, you'd've just typed "I'm lazy." instead.