[Poop-group] Class::DBI 0.32
Michael G Schwern
schwern at pobox.com
Thu Sep 13 05:08:11 CDT 2001
On Wed, Sep 12, 2001 at 11:01:42AM +0100, Tony Bowden wrote:
> So, for the 3 tables:
>
> sock (id, name, yada, yada, yada);
> colour (colourid, name, etc.);
> colour_xref (xrefid, sockid, colour);
>
> we set up:
>
> package Sock;
> use base 'SockDBI';
> Sock->set_up_table('sock');
> Sock->hasa_list('ColourXref', ['sockid'], 'colours');
>
> package ColourXref;
> use base 'SockDBI';
> ColourXref->hasa('SockColour', 'colour');
> sub number { shift->colour->colourid }
> sub name { shift->colour->name }
>
> We can ask for $sock->colours, and then we do a $sock->delete it also
> deletes all the ColourXrefs for that sock, but doesn't delete the colour
> record, which should survive even if there are no socks of that colour
> currently...
Oh, neat! Except you spelt color wrong.
I don't have a copy of 0.32 handy (no net connection), is
this solution to the many-to-many problem in the tutorial?
> All works wonderfully. Throw some Template::Toolkit into the equation and
> designers can be passed a sock, and iterate over the colours etc.
Ahh! A clever solution to the age old "What color socks should I wear
today?"
--
Michael G. Schwern <schwern at pobox.com> http://www.pobox.com/~schwern/
Perl6 Quality Assurance <perl-qa at perl.org> Kwalitee Is Job One
"Let's face it," said bearded Rusty Simmons, opening a can after the
race. "This is a good excuse to drink some beer." At 10:30 in the
morning? "Well, it's past noon in Dublin," said teammate Mike
[Joseph] Schwern. "It's our duty."
-- "Sure, and It's a Great Day for Irish Runners"
Newsday, Sunday, March 20, 1988
More information about the Belfast-pm
mailing list