From 35aed94252e1679246f8d37861f9129df5feb79b Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 11 Dec 2010 15:07:03 +0000 Subject: provided more flexibility in creating the relationships join sql git-svn-id: http://code.elgg.org/elgg/trunk@7596 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/relationships.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'engine/lib/relationships.php') diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index 5e5bf4ecd..ff069fa48 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -257,7 +257,7 @@ function elgg_get_entities_from_relationship($options) { $options = array_merge($defaults, $options); - $clauses = elgg_get_entity_relationship_where_sql('e', $options['relationship'], + $clauses = elgg_get_entity_relationship_where_sql('e.guid', $options['relationship'], $options['relationship_guid'], $options['inverse_relationship']); if ($clauses) { @@ -288,7 +288,8 @@ function elgg_get_entities_from_relationship($options) { * * @todo add support for multiple relationships and guids. * - * @param string $table Entities table name + * @param string $column Column name the guid should be checked against. + * Provide in table.column format. * @param string $relationship Relationship string * @param int $relationship_guid Entity guid to check * @param string $inverse_relationship Inverse relationship check? @@ -296,7 +297,7 @@ function elgg_get_entities_from_relationship($options) { * @return mixed * @since 1.7.0 */ -function elgg_get_entity_relationship_where_sql($table, $relationship = NULL, +function elgg_get_entity_relationship_where_sql($column, $relationship = NULL, $relationship_guid = NULL, $inverse_relationship = FALSE) { if ($relationship == NULL && $entity_guid == NULL) { @@ -309,9 +310,9 @@ $relationship_guid = NULL, $inverse_relationship = FALSE) { $joins = array(); if ($inverse_relationship) { - $joins[] = "JOIN {$CONFIG->dbprefix}entity_relationships r on r.guid_one = e.guid"; + $joins[] = "JOIN {$CONFIG->dbprefix}entity_relationships r on r.guid_one = $column"; } else { - $joins[] = "JOIN {$CONFIG->dbprefix}entity_relationships r on r.guid_two = e.guid"; + $joins[] = "JOIN {$CONFIG->dbprefix}entity_relationships r on r.guid_two = $column"; } if ($relationship) { -- cgit v1.2.3