diff options
author | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-05-21 16:14:51 +0000 |
---|---|---|
committer | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-05-21 16:14:51 +0000 |
commit | 2725ae29f0ac3716a552717fe0965daff312dbd0 (patch) | |
tree | 50a90d72bc795523ebc197e03b24bb7959f27468 /engine/lib | |
parent | 534a834569273b3052918ee7c1a64d56157eccbd (diff) | |
download | elgg-2725ae29f0ac3716a552717fe0965daff312dbd0.tar.gz elgg-2725ae29f0ac3716a552717fe0965daff312dbd0.tar.bz2 |
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
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/relationships.php | 23 |
1 files changed, 23 insertions, 0 deletions
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'");
+ }
+
} /** |