IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 21, 2010, 2:45:13 PM (16 years ago)
Author:
eugene
Message:

merge changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100823/tools/czartool/MySQLDb.pm

    r29124 r29515  
    6464    return $self->{_dbHost};                                                 
    6565}                                                                               
     66###########################################################################
     67#
     68# Adds the provided interval to the provided time
     69#
     70###########################################################################
     71sub getFormattedDate {
     72    my ($self, $time) = @_;
     73
     74    my $query = $self->{_db}->prepare(<<SQL);
     75    SELECT DATE_FORMAT('$time','$self->{_dateFormat}');
     76SQL
     77    $query->execute;
     78
     79    return scalar $query->fetchrow_array();
     80}
    6681
    6782###########################################################################
     
    8398###########################################################################
    8499#
     100# Finds the difference of two times
     101#
     102###########################################################################
     103sub diffTimes {
     104    my ($self, $time1, $time2) = @_;
     105
     106      my $query = $self->{_db}->prepare(<<SQL);
     107         SELECT TIMEDIFF('$time1','$time2');
     108SQL
     109
     110    $query->execute;
     111    return scalar $query->fetchrow_array();
     112}
     113
     114###########################################################################
     115#
     116# Finds the difference of two times in seconds
     117#
     118###########################################################################
     119sub diffTimesInSecs {
     120    my ($self, $time1, $time2) = @_;
     121
     122      my $query = $self->{_db}->prepare(<<SQL);
     123         SELECT TIME_TO_SEC(TIMEDIFF('$time1','$time2'));
     124SQL
     125
     126    $query->execute;
     127    return scalar $query->fetchrow_array();
     128}
     129
     130###########################################################################
     131#
     132# Returns whether the first interval is larger than the second
     133#
     134###########################################################################
     135sub isIntervalGreaterThan {
     136    my ($self, $interval1, $interval2) = @_;
     137
     138      my $query = $self->{_db}->prepare(<<SQL);
     139          SELECT INTERVAL('$interval1', '$interval2');
     140SQL
     141    $query->execute;
     142
     143return scalar $query->fetchrow_array();
     144}
     145
     146###########################################################################
     147#
    85148# Subtracts the provided interval from the provided time
    86149#
     
    127190
    128191return scalar $query->fetchrow_array();
     192}
     193
     194#######################################################################################
     195#
     196# Optimizes a table
     197#
     198#######################################################################################
     199sub optimizeTable {
     200    my ($self, $table) = @_;
     201
     202    my $query = $self->{_db}->prepare(<<SQL);
     203    OPTIMIZE TABLE $table;
     204SQL
     205
     206    my $success = $query->execute;
     207
     208    print "* ";
     209    if (!$success) {print "UN";}
     210    print "successfully optimized '$table' table\n";
     211
     212    return $success;
    129213}
    130214
Note: See TracChangeset for help on using the changeset viewer.