phpfunctionwebrelationshipselgg

Elgg and the utilization of Relationship_created_time_lower


Finishing of my elgg plugin has come to some issues, after fixing my last question I have encountered another. Apperently I am misusing or misunderstanding the use of the Created time lower and upper functions in Elgg

With the code below:

    $monthSpan = (30 * 24 * 60 * 60);
$startTime = time() - $monthSpan;

$MemberDifference = elgg_get_entities_from_relationship(array(
    'relationship' => 'member', //get Members
    'relationship_guid' => $group->guid, //get individual guid for use
    'inverse_relationship' => true,
    'type' => 'user', //users are returned
    'limit' => 20,
    'joins' => array("JOIN {$db_prefix}users_entity u ON e.guid=u.guid"),
    'order_by' => 'u.name ASC',
    'relationship_created_time_lower' => $startTime, //the furthest back it will reach
    'relationship_created_time_upper' => time(), //possibly unneeded, but ensures the closest date is today
    'count' => true,
));

Using this function, I built it upon my way to get all of the members in the associated group, theoretically it should now grab any members that registered to that group within the last month. Unfortunately, it instead continues to grab every member in the group, regardless of the time they joined.

Does anyone have any information into where I have went wrong?


Solution

  • Turns out, my version of Elgg was too low, otherwise that entire block of code would work. Working Elgg 1.8, I needed to use the following code:

            $MemberDifference = elgg_get_entities_from_relationship_count(array(
                'relationship' => 'member',
                'relationship_guid' => $Reports->guid,
                'inverse_relationship' => true,
                'type' => 'user',
                'limit' => 20,
                'count' => true,
                'joins' => array("JOIN {$db_prefix}users_entity u ON e.guid=u.guid"),
                'order_by' => 'u.name ASC',
                'wheres' => array('r.time_created >=' . $startTime)
            ));
    

    This works perfectly and brings about exactly what im looking for.