elgg_get_entities_from_relationship with multi 'relationship_guid'

how is it possible to get a relationship_guid for multi guid in simple way?

$rocks = elgg_get_entities_from_relationship(array( 'relationship' => 'child', 'relationship_guid' => 'multiguid', 'inverse_relationship' => 'false', 'metadata_name' => 'level', 'metadata_value' => '5', 'type' => 'object', 'subtype' => 'music', 'order_by' => '', 'limit' => 100));

  • I don't understand your question.

  • I'm tring to get_entities_from_relationship from more specific $guid () at once (multi guid)

    $member_guid = (2,10,15,18,20,....)


    relationship_guid => $member_guid

    to return entities matching a given query joining against a more relationship and guid at once.

  • Sorry - still don't understand. Are you trying to do something like: "give me all the friends of Bob, Harry, and Sam" rather than the typical usage: "give me all the friends of Bob"?

  • sorry me for my english :-(

    yes like "give me all the friends of Bob, Harry, and Sam"

  • That function doesn't support this by default. You should be able to pass a custom where clause to get this:

    'wheres' => array('r.guid_two IN (1,2,3)'),

    Note, you may need to use r.guid_one and change the inverse relationship flag depending on what you're trying to do.

    Also, you could open up a trac ticket asking for support for multiple GUIDs when using this function.

  • it would be good if function in fact supported multiple relationships, not only guids, eg. get all who are in relationship of "member" and in relationship of "invited". It could work like metadata array. (I added this comment to trac)

  • Yes. I agree with Mike, multiple relationships is better.

  • What about if I want to get members that are friends of somebody and are members of a group at the same? how to implement a custom sql clause to do it?

  • could be implemented in raw mysql using sub-queries ->
    WHERE    member-guid IN
            (   SUB-SELECT    member-guid FROM RELATIONSHIPS
                WHERE RELATIONSHIP = member
            &&  member-guid IN
                (    SUB-SELECT    friend-guid FROM RELATIONSHIPS
                     WHERE RELATIONSHIP = friend
                &&   owner-guid= self-guid

    though should be coded using equivalent elgg api logic =>