the naming is very important. this means your packages have to have the same name as the database tables.

Actually, this is not true. When you call has_a, you just have to give it the name of an accessor in the current class that will return the primary key for the other class. You give your accessors any name you like. For example, I could change your example like this:

package MyPackage::User; use base ('MyPackage'); MyPackage::User->table('user'); MyPackage::User->columns(Essential => qw(id role_id name lastname)); __PACKAGE__->has_a(wild_and_crazy_role => 'MyPackage::Role'); sub accessor_name { my ($class, $column) = @_; $column =~ s/role_id/wild_and_crazy_role/; return $column; }

In reply to Re: Re: Class::DBI global questions and references (partly explained, waiting for more ;) by perrin
in thread Class::DBI global questions and references by ile

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.