Changeset 165 for trunk/lib/Vote/DB


Ignore:
Timestamp:
04/06/09 02:13:06 (15 years ago)
Author:
nanardon
Message:
  • add Vote::DB::Choice object
Location:
trunk/lib/Vote/DB
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Vote/DB/Poll.pm

    r161 r165  
    1010use Vote::DB::Ballot; 
    1111use Vote::DB::Voting; 
     12use Vote::DB::Choice; 
    1213 
    1314=head1 NAME 
     
    212213} 
    213214 
     215sub choice { 
     216    my ($self, $chid) = @_; 
     217     
     218    my $sth = $self->db->prepare_cached( 
     219        q{ 
     220        select key from choice where poll = ? and key = ? 
     221        } 
     222    ); 
     223    $sth->execute($self->voteid, $chid); 
     224    my $res = $sth->fetchrow_hashref; 
     225    $sth->finish; 
     226    return $res ? Vote::DB::Choice->new($self->{dbstring}, $chid) : undef; 
     227} 
     228 
    214229sub choices { 
    215230    my ($self) = @_; 
     
    242257 
    243258    1 
     259} 
     260 
     261sub delete_choice { 
     262    my ($self, $chid) = @_; 
     263 
     264    my $sth = $self->db->prepare_cached( 
     265        q{delete from choice where key = ?} 
     266    ); 
     267 
     268    $sth->execute($chid); 
    244269} 
    245270 
Note: See TracChangeset for help on using the changeset viewer.