source: trunk/lib/Vote/DB/Choice.pm @ 193

Last change on this file since 193 was 165, checked in by nanardon, 15 years ago
  • add Vote::DB::Choice object
  • Property svn:keywords set to Id Rev
File size: 950 bytes
Line 
1package Vote::DB::Choice;
2
3# $Id$
4
5use strict;
6use warnings;
7use base 'Vote::DB::common';
8use Vote::DB::Poll;
9
10=head1 NAME
11
12Vote::Model::Vote - Catalyst Model
13
14=head1 DESCRIPTION
15
16Catalyst Model.
17
18=cut
19
20sub new {
21    my ($class, $dbstring, $key) = @_;
22   
23    bless {
24        key => $key,
25        dbstring => $dbstring,
26        db => Vote::DB::common::_newdb($dbstring),
27    }, $class;
28}
29
30sub choicekey { $_[0]->{key} }
31
32sub poll {
33    my ($self) = @_;
34    Vote::DB::Poll->new($self->{dbstring}, $self->info->{poll});
35}
36
37sub info {
38    my ($self) = @_;
39
40    my $sth = $self->db->prepare_cached(
41        q{
42        select * from choice where key = ?
43        }
44    );
45    $sth->execute($self->choicekey);
46
47    my $res = $sth->fetchrow_hashref;
48    $sth->finish;
49    $res
50}
51
52=head1 AUTHOR
53
54Thauvin Olivier
55
56=head1 LICENSE
57
58This library is free software, you can redistribute it and/or modify
59it under the same terms as Perl itself or CeCILL.
60
61=cut
62
631;
Note: See TracBrowser for help on using the repository browser.