Alex Povolotsky wrote:
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
Is gid the gallery id? If so, that query would count the number of
photos in all albums in that gallery. Have you mis-identified gid as
the primary key of Album?
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?
That should be equivalent to the first query.
_______________________________________________
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]