]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
provided more flexibility in creating the relationships join sql
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 11 Dec 2010 15:07:03 +0000 (15:07 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 11 Dec 2010 15:07:03 +0000 (15:07 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7596 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/relationships.php

index 5e5bf4ecd0c04d98a4c96df02a573eb5974a4c8b..ff069fa487030a8476fa844e698d3d80939d662e 100644 (file)
@@ -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) {