From 2725ae29f0ac3716a552717fe0965daff312dbd0 Mon Sep 17 00:00:00 2001 From: ben Date: Wed, 21 May 2008 16:14:51 +0000 Subject: Added function to remove all entity relationships of a particular kind associated with an entity git-svn-id: https://code.elgg.org/elgg/trunk@671 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/relationships.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'engine/lib') diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index 8e3298a61..28c7ba604 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -340,6 +340,29 @@ $guid_two = (int)$guid_two; return delete_data("DELETE from {$CONFIG->dbprefix}entity_relationships where guid_one=$guid_one and relationship='$relationship' and guid_two=$guid_two"); + } + + /** + * Removes all arbitrary relationships originating from a particular entity + * + * @param int $guid_one The GUID of the entity + * @param string $relationship The name of the relationship + * @param true|false $inverse Whether we're deleting inverse relationships (default false) + * @return true|false Depending on success + */ + function remove_entity_relationships($guid_one, $relationship, $inverse = false) { + + global $CONFIG; + + $guid_one = (int) $guid_one; + $relationship = sanitise_string($relationship); + + if (!$inverse) { + return delete_data("DELETE from {$CONFIG->dbprefix}entity_relationships where guid_one=$guid_one and relationship='$relationship'"); + } else { + return delete_data("DELETE from {$CONFIG->dbprefix}entity_relationships where guid_two=$guid_one and relationship='$relationship'"); + } + } /** -- cgit v1.2.3