[Dbix-class] has_many relationship docs
Tim McIntyre
tmac at easystreet.com
Wed Mar 1 18:24:37 CET 2006
Hey all,
I'm trying out DBIC for the first time and something in the docs has
me scratching my head. I'm pretty sure I'm just completely
misunderstanding something but this seems odd to me.
From the docs:
# in a Foo class (where Foo has many Bars)
__PACKAGE__->has_many(bar => Bar, 'foo');
my $f_resultset = $obj->foo;
my $f_resultset = $obj->foo({ name => { LIKE => '%macaroni%' },
{ prefetch => [qw/bar/]});
my @f_obj = $obj->foo;
$obj->add_to_foo(\%col_data);
This is where my head is:
# in a Foo class (where Foo has many Bars)
__PACKAGE__->has_many(bars => "My::Bar", 'foo_id');
# back in the main package or wherever
my $bars = $foo_object->bars;
$foo_object->add_to_bars(\%col_data);
1) Other than the prefetch example I don't see where the foo method
calls from the doc example come into play here?
2) Why can't you pass instances to the add_to_* methods?
Sorry about this but UGH!... IMHO foo, bar examples suck! They are
just too generic. More realistic examples are much more helpful to
us newbies.
Looks like a great project though, I'm excited.
Thanks in advance!
Tim McIntyre
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/dbix-class/attachments/20060301/6f01c0cd/attachment.htm
More information about the Dbix-class
mailing list