/** * An orphaned relationship does not correspond to an allowable relationship in the allowable relationship table and should be deleted * @todo move into a database maintenance class which separated detection from deletion * @return number of deleted orphaned relationships */ function remove_orphaned_relationships() { $ids = get_orphaned_relationship_ids(); if (count($ids) > 0) { $q = 'DELETE FROM relationship where `id` IN ("'.implode('","', $ids).'")'; $result = db_query($q); return count($ids); } else return 0; }
/** * If the number to delete is huge we'll do it in chunks */ function remove_orphaned_relationships() { echo '<hr/>'; $orphans = get_orphaned_relationship_ids(); if ($this->mode == 'run') { if (count($orphans) > 0) { $deleted_count = remove_orphaned_relationships(); echo '<p>Removed ' . $deleted_count . ' orphaned relationships.</p>'; } else { echo '<p>Nothing to delete there are no orphaned relationships.</p>'; } } else { echo '<p>Would delete ' . count($orphans) . ' orphaned relationships (this may be inaccurate if the previous steps would delete allowable relationships).</p>'; } }