From 0acf3e0e30dbe9b127f5e307619e7ee72eb4e9cc Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Wed, 18 Feb 2015 14:01:35 +0100 Subject: [PATCH] Profile table cleaning script. --- scripts/clean_profiles.php | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 scripts/clean_profiles.php diff --git a/scripts/clean_profiles.php b/scripts/clean_profiles.php new file mode 100755 index 0000000000..470d6c1b91 --- /dev/null +++ b/scripts/clean_profiles.php @@ -0,0 +1,59 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'y'; +$longoptions = array('yes'); + +$helptext = <<query('SELECT * FROM profile WHERE ' . + 'NOT (SELECT COUNT(*) FROM notice WHERE profile_id=profile.id) ' . + 'AND NOT (SELECT COUNT(*) FROM user WHERE user.id=profile.id) ' . + 'AND NOT (SELECT COUNT(*) FROM user_group WHERE user_group.profile_id=profile.id) ' . + 'AND NOT (SELECT COUNT(*) FROM subscription WHERE subscriber=profile.id OR subscribed=profile.id) '); +while ($profile->fetch()) { + echo ' '.$profile->getID().':'.$profile->getNickname(); + $profile->delete(); +} +print "\nDONE.\n"; -- 2.39.5