diff options
author | Aleksander Machniak <alec@alec.pl> | 2014-09-22 09:31:11 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2014-09-22 09:31:11 +0200 |
commit | ff767a14ff7675fce7b23b918f41fa92157dd0c0 (patch) | |
tree | f7a1ed9a6c7d5ec02e967278ff6301019258ead5 /bin/cleandb.sh | |
parent | 13bbcd0f59ef7a4459a6909079f0a558913e808a (diff) | |
parent | abc00f27c5d923a02c946a634e158dfe9f20974e (diff) |
Merge branch 'oracle'
Diffstat (limited to 'bin/cleandb.sh')
-rwxr-xr-x | bin/cleandb.sh | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/bin/cleandb.sh b/bin/cleandb.sh index 165d33f38..9edfeec91 100755 --- a/bin/cleandb.sh +++ b/bin/cleandb.sh @@ -48,7 +48,7 @@ $threshold = date('Y-m-d 00:00:00', time() - $days * 86400); foreach (array('contacts','contactgroups','identities') as $table) { - $sqltable = $db->table_name($table); + $sqltable = $db->table_name($table, true); // also delete linked records // could be skipped for databases which respect foreign key constraints @@ -59,10 +59,10 @@ foreach (array('contacts','contactgroups','identities') as $table) { $memberstable = $db->table_name('contactgroupmembers'); $db->query( - "DELETE FROM $memberstable". - " WHERE $pk IN (". - "SELECT $pk FROM $sqltable". - " WHERE del=1 AND changed < ?". + "DELETE FROM " . $db->quote_identifier($memberstable). + " WHERE `$pk` IN (". + "SELECT `$pk` FROM $sqltable". + " WHERE `del` = 1 AND `changed` < ?". ")", $threshold); @@ -70,7 +70,7 @@ foreach (array('contacts','contactgroups','identities') as $table) { } // delete outdated records - $db->query("DELETE FROM $sqltable WHERE del=1 AND changed < ?", $threshold); + $db->query("DELETE FROM $sqltable WHERE `del` = 1 AND `changed` < ?", $threshold); echo $db->affected_rows() . " records deleted from '$table'\n"; } |