Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Class::DBI Intro

by mojotoad (Monsignor)
on Jul 30, 2003 at 19:42 UTC ( #279345=note: print w/ replies, xml ) Need Help??


in reply to Class::DBI Intro

Nice tutorial. ++

A number of things I'd be curious to see added:

  • Autocreation of table classes via Class::DBI::mysql and ilk. (Class::DBI::Loader seems to be aimed at mod_perl? If not, how do these differ?)
  • Some exposition on handling joins via the has_many() call with mapping syntax, i.e. from the docs:

    Music::CD->has_many(styles => [ 'Music::StyleRef' => 'style' ]);

    is identical to

    Music::CD->has_many(_style_refs => 'Music::StyleRef'); sub styles { my $self = shift; return map $_->style, $self->_style_refs; }

    (but note that your join table still requires a primary key)

  • Real bridging of object heirarchies into relational databases using toys such as Class::DBI::SAK, which integrate lots of approaches such as that taken by Class::Tangram (or at least, so I hear)

Good stuff,
Matt


Comment on Re: Class::DBI Intro
Select or Download Code
Re: Re: Class::DBI Intro
by salvadors (Pilgrim) on Aug 01, 2003 at 07:58 UTC

    (but note that your join table still requires a primary key)

    Actually, it doesn't always. As long as the relationship is unique, the cross-reference itself can be treated as a multi-column primary key, even if it isn't defined as such in the database.

    Strange things can happen with this if you step off the (admittedly very narrow) beaten path, but for general cross-referencing it seems to work just fine.

    Tony

      Actually, it doesn't always. As long as the relationship is unique, the cross-reference itself can be treated as a multi-column primary key, even if it isn't defined as such in the database.

      Can you give an example? I'm still learning about Class::DBI, but thus far I have not found a way to avoid it claiming the first column as a primary key (in the absence of such a declaration in the DB table itself).

      Matt

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://279345]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2014-10-20 09:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (75 votes), past polls