make cleanup of database database independent

This commit is contained in:
2018-04-24 14:55:40 +02:00
parent a6ce908f4b
commit d9e65f4b5d

View File

@@ -125,17 +125,19 @@ foreach ($mx_db->query($sql) as $row) {
try { try {
//cleanup: all finished entries older than one month //cleanup: all finished entries older than one month
$timestamp = date('Y-m-d H:m:s',strtotime("-1 month"));
$mx_db->query("DELETE FROM registrations " $mx_db->query("DELETE FROM registrations "
. "WHERE request_date < (datetime('now', '-1 month')) " . "WHERE request_date < '$timestamp'"
. " AND (state = " . RegisterState::RegistrationDeclined . " AND (state = " . RegisterState::RegistrationDeclined
. " OR state = " . RegisterState::AllDone . " );" . " OR state = " . RegisterState::AllDone . " );"
); );
//cleanup: all entries which are pending email registration older than two days //cleanup: all entries which are pending email registration older than two days
$timestamp = date('Y-m-d H:m:s',strtotime("-2 days"));
$mx_db->query("DELETE FROM registrations " $mx_db->query("DELETE FROM registrations "
. "WHERE request_date < (datetime('now', '-2 days')) " . "WHERE request_date < '$timestamp'"
. " AND state = " . RegisterState::PendingEmailVerify . ";" . " AND state = " . RegisterState::PendingEmailVerify . ";"
); );
} catch (Exception $ex) { } catch (Exception $e) {
print("Error while database cleanup\n"); print("Error while database cleanup\n");
print($e->getMessage()); print($e->getMessage());
} }