[Dbix-class] DBIx::Class troubles with retrieving thread replycount on discussion software
Marc Logghe
Marc.Logghe at DEVGEN.com
Fri Sep 29 08:56:51 CEST 2006
Hi,
I guess it has to do with the fact you make use of an alias (count). You
can not access this as a normal column because the accessor is not
available. You have to use the get_column('count') accessor instead.
Don't shoot me if this is total nonsense, I am pretty new at this as
well ;-)
Cheers,
Marc
________________________________
From: dbix-class-bounces at lists.rawmode.org
[mailto:dbix-class-bounces at lists.rawmode.org] On Behalf Of Devin Austin
Sent: Friday, September 29, 2006 8:02 AM
To: dbix-class at lists.rawmode.org
Subject: [Dbix-class] DBIx::Class troubles with retrieving
thread replycount on discussion software
Hi everyone, I'm new to this, but I thought I'd post a question.
I"m having trouble trying to retrieve the reply count to each
thread in my message board software (
http://www.timorperfectus.com/users/devin/
<http://www.timorperfectus.com/users/devin/> ). I've tried a few
things, but this is the current code I'm trying to get to work:
my $comments = $schema->resultset('News')->search(
{
replyid => 0
},
{
rows => 3,
page => scalar $q->param('page') || 1,
order_by => 'date DESC'
}
);
## let's get the comments
for ( $comments->all ) {
my $count = $schema->resultset('News')->search(
{
replyid => $_->postid
},
{
select => [
{
count => '*'
}
],
as => [ 'count' ]
}
);
my $c = $count->next;
my %row_data;
$row_data{'post_subject'} = $_->subject;
$row_data{'post_author'} = $_->author;
$row_data{'post_date'} = $_->date;
$row_data{'post_id'} = $_->postid;
$row_data{'post_content'} = $_->story;
$row_data{'replies'} = $c->count;
#$row_data{'is_hidden'} = $_->is_hidden;
# push it into the the loop....
push ( @end_posts, \%row_data );
}
If this is too much code to look at let me know and I'll trim it
down...anyone have any ideas? Do you need to see my schema?
Thanks!
-devin
--
timorperfectus.com - web design to frightening perfection.
One last song
Given to an Angel's Son
As soon as you were gone
As soon as you were gone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/dbix-class/attachments/20060929/85fd5bbe/attachment.htm
More information about the Dbix-class
mailing list