Last change
on this file since 181 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
|
Rev | Line | |
---|
[165] | 1 | package Vote::DB::Choice; |
---|
| 2 | |
---|
| 3 | # $Id$ |
---|
| 4 | |
---|
| 5 | use strict; |
---|
| 6 | use warnings; |
---|
| 7 | use base 'Vote::DB::common'; |
---|
| 8 | use Vote::DB::Poll; |
---|
| 9 | |
---|
| 10 | =head1 NAME |
---|
| 11 | |
---|
| 12 | Vote::Model::Vote - Catalyst Model |
---|
| 13 | |
---|
| 14 | =head1 DESCRIPTION |
---|
| 15 | |
---|
| 16 | Catalyst Model. |
---|
| 17 | |
---|
| 18 | =cut |
---|
| 19 | |
---|
| 20 | sub 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 | |
---|
| 30 | sub choicekey { $_[0]->{key} } |
---|
| 31 | |
---|
| 32 | sub poll { |
---|
| 33 | my ($self) = @_; |
---|
| 34 | Vote::DB::Poll->new($self->{dbstring}, $self->info->{poll}); |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | sub 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 | |
---|
| 54 | Thauvin Olivier |
---|
| 55 | |
---|
| 56 | =head1 LICENSE |
---|
| 57 | |
---|
| 58 | This library is free software, you can redistribute it and/or modify |
---|
| 59 | it under the same terms as Perl itself or CeCILL. |
---|
| 60 | |
---|
| 61 | =cut |
---|
| 62 | |
---|
| 63 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.