Changeset 193 for trunk/lib/Vote/DB
- Timestamp:
- 04/14/09 18:19:40 (15 years ago)
- Location:
- trunk/lib/Vote/DB
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Vote/DB/Poll.pm
r191 r193 527 527 } 528 528 529 sub ballot_count_nonull {530 my ($self) = @_;531 532 my $sth = $self->db->prepare_cached(533 q{534 select count(*) from ballot where poll = ?535 and id in (select id from ballot_item) and536 (invalid = 'false' or invalid is null)537 }538 );539 540 $sth->execute($self->voteid);541 my $res = $sth->fetchrow_hashref;542 $sth->finish;543 $res->{count}544 }545 546 529 sub voting_info_id { 547 530 my ($self, $mail) = @_; … … 601 584 602 585 return 1; 603 }604 605 sub results_count {606 my ($self) = @_;607 608 my $sth = $self->db->prepare(609 q{610 select count(ballot.id), value from611 (select ballot.id, coalesce(corrected, value) as "value" from ballot left join ballot_item612 on ballot.id = ballot_item.id where ballot.poll = ? and (invalid = 'false'or invalid is null)613 group by ballot.id, coalesce(corrected, value)) as ballot614 group by value615 order by count desc, value616 }617 );618 $sth->execute($self->voteid);619 my @results;620 while (my $res = $sth->fetchrow_hashref) {621 push(@results, $res);622 }623 @results;624 }625 626 sub results_nonull {627 my ($self) = @_;628 629 my $sth = $self->db->prepare(630 q{631 select count(ballot.id), value from632 (select ballot.id, coalesce(corrected, value) as "value" from ballot join ballot_item633 on ballot.id = ballot_item.id where ballot.poll = ? and (invalid = 'false'or invalid is null)634 group by ballot.id, coalesce(corrected, value)) as ballot635 group by value636 order by count desc, value637 }638 );639 $sth->execute($self->voteid);640 my @results;641 while (my $res = $sth->fetchrow_hashref) {642 push(@results, $res);643 }644 \@results;645 586 } 646 587
Note: See TracChangeset
for help on using the changeset viewer.