From 1bb2b3f8572c087b20ef5649fa1463a35374521f Mon Sep 17 00:00:00 2001 From: ben Date: Fri, 14 Mar 2008 16:26:26 +0000 Subject: Adding a couple of extra functions, deleting the old users module git-svn-id: https://code.elgg.org/elgg/trunk@224 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/entities.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'engine/lib/entities.php') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 5fd16461d..cab9afae6 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -555,6 +555,28 @@ $guid_two = (int)$guid_two; return insert_data("INSERT into {$CONFIG->dbprefix}entity_relationships (guid_one, relationship, guid_two) values ($guid_one, 'relationship', $guid_two)"); + } + + /** + * Determine whether or not a relationship between two entities exists + * + * @param int $guid_one The GUID of the entity "owning" the relationship + * @param string $relationship The type of relationship + * @param int $guid_two The GUID of the entity the relationship is with + * @return true|false + */ + function check_entity_relationship($guid_one, $relationship, $guid_two) + { + global $CONFIG; + + $guid_one = (int)$guid_one; + $relationship = sanitise_string($relationship); + $guid_two = (int)$guid_two; + + if ($row = get_data_row("select guid_one from {$CONFIG->dbprefix}entity_relationships where guid_one=$guid_one and relationship='$relationship' and guid_two=$guid_two limit 1")) { + return true; + } + return false; } /** @@ -572,7 +594,7 @@ $relationship = sanitise_string($relationship); $guid_two = (int)$guid_two; - return insert_data("DELETE from {$CONFIG->dbprefix}entity_relationships where guid_one=$guid_one and relationship='$relationship' and guid_two=$guid_two"); + return delete_data("DELETE from {$CONFIG->dbprefix}entity_relationships where guid_one=$guid_one and relationship='$relationship' and guid_two=$guid_two"); } -- cgit v1.2.3