summaryrefslogtreecommitdiff
path: root/bin/cleandb.sh
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2014-09-22 09:31:11 +0200
committerAleksander Machniak <alec@alec.pl>2014-09-22 09:31:11 +0200
commitff767a14ff7675fce7b23b918f41fa92157dd0c0 (patch)
treef7a1ed9a6c7d5ec02e967278ff6301019258ead5 /bin/cleandb.sh
parent13bbcd0f59ef7a4459a6909079f0a558913e808a (diff)
parentabc00f27c5d923a02c946a634e158dfe9f20974e (diff)
Merge branch 'oracle'
Diffstat (limited to 'bin/cleandb.sh')
-rwxr-xr-xbin/cleandb.sh12
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";
}