Back to my Music database. In my Cd class I have these methods to return
counts of tracks of a specific type.
sub foo_track_type_count {
return shift->tracks( { track_type => 1 } )->count; # any different
then count_related??
}
sub bar_track_type_count {
return shift->tracks( { track_type => { -in => [2,3] } } )->count;
}
Now, it turns out that I always need these counts.
$cd => $schema->resultset( 'Cd' )->find( $id ); # one database select
my $foos = $cd->foo_track_count; # second select
my $bars = $cd->bar_track_count; # third.
I know I can build a resultset that includes a total count (as seen in the
Cookbook), but is there a way to include counts that are limited to those
specific "track_types"?
IIRC from past discussions this had to be done with a custom FROM which then
broke some other functionality.
--
Bill Moseley
[email protected]
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]