CDBI::Pager and has_many
[prev]
[thread]
[next]
[Date index for 2004/08/29]
Hi!
Is there a way to have the Pager work with has_many relationships?
I'm trying to do:
my $cd = CD->retrieve(1);
my $pager = $cd->pager;
my $tracks = $pager->tracks;
in order to page through the tracks for a specific CD, but it doesn't
seem to return Tracks. It's returning CD's instead, which is a pity.
What's happening internally is that CDBI is retrieving the correct
records, but the Pager is converting them to the CD class.
It does make sense that it works like this, given the source code, but
is there a way around this? Could I pass an iterator to CDBI::Pager to
work with instead of getting it through the $class->pager->$method ?
The reason I ask is that my has_many relationship also defines a sort
order. I could of course get the Pager through the Tracks class and
query it with the appropriate parameters, but I don't like to repeat the
things defined in the relationship. That would mean two places to edit
(and in client code no less) if there's changes in the relationship.
Thanks,
Rhesa Rozendaal
|
CDBI::Pager and has_many
Rhesa Rozendaal 19:45 on 29 Aug 2004
|