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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Devin Austin
Sent: Friday, September 29, 2006 8:02 AM
To: [email protected]
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/).  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
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to