[Dbix-class] How to count?...
Alex Povolotsky
tarkhil at over.ru
Mon Mar 24 20:35:30 GMT 2008
Hello!
I have a simple tree-like structure of galleries, albums and photos; to
count photos in all albums, I've tried to
sub count_photos {
my $self = shift;
return $self->photos->search->count;
}
in Album class.
However, this yields
SELECT COUNT( * ) FROM album me LEFT JOIN photo photos ON ( photos.aid =
me.aid ) WHERE ( me.gid = ? ): '1'
which apparently returns wrong result. Can I somehow
select count(*) from photo photos LEFT JOIN album me ON ( photos.aid =
me.aid ) WHERE ( me.gid = ? ) ?
Or am I missing something quite SQL-trivial?
Alex.
More information about the DBIx-Class
mailing list