diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-11 15:07:03 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-11 15:07:03 +0000 |
commit | 35aed94252e1679246f8d37861f9129df5feb79b (patch) | |
tree | e2c635c3b2054b89c5eb21a3b480746e2419b492 /engine/lib/relationships.php | |
parent | 8a2982ab71a5508f3e4c914a7945db8f1132c5a1 (diff) | |
download | elgg-35aed94252e1679246f8d37861f9129df5feb79b.tar.gz elgg-35aed94252e1679246f8d37861f9129df5feb79b.tar.bz2 |
provided more flexibility in creating the relationships join sql
git-svn-id: http://code.elgg.org/elgg/trunk@7596 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/relationships.php')
-rw-r--r-- | engine/lib/relationships.php | 11 |
1 files changed, 6 insertions, 5 deletions
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) { |