function remove_allowable_relationships_with_missing_types() { echo '<hr/>'; $ids = get_allowable_relationships_with_missing_types(); if ($this->mode == 'run') { if (count($ids) > 0) { $deleted_count = remove_allowable_relationships_with_missing_types(); echo '<p>Removed ' . $deleted_count . ' allowable relationships with missing types.</p>'; } else { echo '<p>Nothing to delete there are no allowable relationships with missing types.</p>'; } } else { echo '<p>Would delete ' . count($ids) . ' allowable relationships with missing types.</p>'; } }
/** * Examines the allowable relationships table, removes allowable relationships that reference a type that does not exist * * @todo database abstraction * @todo move into a database maintenance class * @return number of deleted allowable_relationships * @author Nathan White */ function remove_allowable_relationships_with_missing_types() { $ids = get_allowable_relationships_with_missing_types(); if (!empty($ids)) { $ids_to_delete = implode(',', $ids); $q = 'DELETE from allowable_relationship WHERE id IN ('.$ids_to_delete.')'; db_query($q); reason_refresh_relationship_names(); return count($ids); } return 0; }