in reply to retrieving the reply count of a thread using regular ol' DBI and CGI::Application
for ( scalar $rows_data ) { $sth2->execute($_); my $count = $sth2->fetchrow_array; push @$rows_data, { count => $count }
1. Where does $rows_data come from? It looks like an arrayref, so you should treat it as such. Are you trying to get the number of elements in it, or are you iterating over it? If the former, then do for( scalar @$rows_data ); if the latter, do for( @$rows_data )
2. Pushing new values onto an array you're iterating over is likely to confuse the for() loop, and won't do what you want. Try using a new array for your hashrefs.
That being said, are you sure one of Class::DBI's count() methods or one of the Count plugins won't be able to do this for you more effeciently?
It's not entirely clear what you are trying to put together. Could you give us a better description of your data model, and your desired output model?
|
|---|