Re: Problem with empty has_a
[prev]
[thread]
[next]
[Date index for 2005/05/20]
Hi!
On Fri, May 20, 2005 at 09:05:01AM +0200, Thomas Klausner wrote:
> In fact might_have works as well. D'oh!
Well, after more testing: It only works in one direction.
Here's what I'm trying to do:
- I have a bunch of events.
- I have another bunch of publications.
- A publication might be releated to a single event (e.g. a paper of a
presentation given at an event).
- An event might have several publications releated to it.
- Provide links between both events and publications.
My initial plan was:
My::Publication->has_a(event=>'My::Event');
My::Event->has_many(publications=>'My::Publications'=>'event');
This worked, but every publication had an empty event (as in my original
posting)
So I switched to:
My::Publication->might_have(event=>'My::Event');
My::Event->has_many(publications=>'My::Publications'=>'event');
But this does not work, because has_many doesn't find the 'event' field in
publications ("event is not a column of My::Publikations")
Now I could simply write some work-aournd code using my first attempt:
sub My::Publication::clean_event {
my $event=shift->event;
return $event if $event->id > 0;
}
But I'd rather find a general solution. Whether this is a patch to
Class::DBI or a special Class::DBI::Relationship on CPAN I don't care.
I would just need a pointer to what you (Tony and all others) prefere..
--
#!/usr/bin/perl http://domm.zsi.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}