Changeset 190 for trunk/lib/Vote/DB


Ignore:
Timestamp:
04/13/09 04:08:15 (15 years ago)
Author:
nanardon
Message:
  • check dates coherencies in poll settings
File:
1 edited

Legend:

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

    r160 r190  
    7777} 
    7878 
     79sub valid_date { 
     80    my ($self, $date) = @_; 
     81    my $res = $self->db->do( 
     82        sprintf( 
     83            q{ select %s::timestamp }, 
     84            $self->db->quote($date), 
     85        ) 
     86    ); 
     87    $res or $self->db->rollback; 
     88} 
     89 
     90sub check_date_max { 
     91    my ($self, $maxdate, $mindate) = @_; 
     92    my $sth = $self->db->prepare( 
     93        sprintf( 
     94            q{ select %s::timestamp > %s::timestamp as res }, 
     95            $self->db->quote($maxdate), 
     96            $mindate ? $self->db->quote($mindate) : 'now()', 
     97        ) 
     98    ); 
     99    $sth->execute or do { 
     100        $self->db->rollback; 
     101        return; 
     102    }; 
     103    my $res = $sth->fetchrow_hashref; 
     104    $sth->finish; 
     105    $res->{res} 
     106} 
     107 
    79108sub gen_uid { 
    80109    unpack("H*", join("", map { chr(rand(256)) } (0..15))) 
Note: See TracChangeset for help on using the changeset viewer.