Changeset 29282
- Timestamp:
- Sep 30, 2010, 1:47:22 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/perl/ippToPsps/MySQLDb.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/perl/ippToPsps/MySQLDb.pm
r28757 r29282 65 65 } 66 66 67 68 67 ########################################################################### 69 68 # 70 # Returns 'now' as a timestamp69 # Adds the provided interval to the provided time 71 70 # 72 71 ########################################################################### 73 sub getIntervalInPast{74 my ($self, $ interval) = @_;72 sub addInterval { 73 my ($self, $time, $interval) = @_; 75 74 76 75 my $query = $self->{_db}->prepare(<<SQL); 77 SELECT now() -INTERVAL $interval;76 SELECT '$time' + INTERVAL $interval; 78 77 SQL 79 78 $query->execute; … … 82 81 } 83 82 83 ########################################################################### 84 # 85 # Subtracts the provided interval from the provided time 86 # 87 ########################################################################### 88 sub subtractInterval { 89 my ($self, $time, $interval) = @_; 90 91 my $query = $self->{_db}->prepare(<<SQL); 92 SELECT '$time' - INTERVAL $interval; 93 SQL 94 $query->execute; 95 96 return scalar $query->fetchrow_array(); 97 } 98 99 ########################################################################### 100 # 101 # Returns whether time1 is before time2 102 # 103 ########################################################################### 104 sub isBefore { 105 my ($self, $time1, $time2) = @_; 106 107 my $query = $self->{_db}->prepare(<<SQL); 108 SELECT '$time1' < '$time2'; 109 SQL 110 $query->execute; 111 112 return scalar $query->fetchrow_array(); 113 } 84 114 85 115 ########################################################################### … … 97 127 98 128 return scalar $query->fetchrow_array(); 129 } 130 131 ####################################################################################### 132 # 133 # Optimizes a table 134 # 135 ####################################################################################### 136 sub optimizeTable { 137 my ($self, $table) = @_; 138 139 my $query = $self->{_db}->prepare(<<SQL); 140 OPTIMIZE TABLE $table; 141 SQL 142 143 my $success = $query->execute; 144 145 print "* "; 146 if (!$success) {print "UN";} 147 print "successfully optimized '$table' table\n"; 148 149 return $success; 99 150 } 100 151
Note:
See TracChangeset
for help on using the changeset viewer.
