Elgg
Version 1.11
|
Public Member Functions | |
__construct () | |
Constructor. More... | |
get ($id) | |
Get a relationship by its ID. More... | |
getRow ($id) | |
Get a database row from the relationship table. More... | |
delete ($id) | |
Delete a relationship by its ID. More... | |
add ($guid_one, $relationship, $guid_two) | |
Create a relationship between two entities. More... | |
check ($guid_one, $relationship, $guid_two) | |
Check if a relationship exists between two entities. More... | |
remove ($guid_one, $relationship, $guid_two) | |
Delete a relationship between two entities. More... | |
removeAll ($guid, $relationship="", $inverse_relationship=false, $type= '') | |
Removes all relationships originating from a particular entity. More... | |
getAll ($guid, $inverse_relationship=false) | |
Get all the relationships for a given GUID. More... | |
getEntities ($options) | |
Return entities matching a given query joining against a relationship. More... | |
getEntityRelationshipWhereSql ($column, $relationship=null, $relationship_guid=null, $inverse_relationship=false) | |
Returns SQL appropriate for relationship joins and wheres. More... | |
getEntitiesFromCount (array $options=array()) | |
Gets the number of entities by a the number of entities related to them in a particular way. More... | |
Definition at line 13 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::__construct | ( | ) |
Constructor.
Definition at line 24 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::add | ( | $guid_one, | |
$relationship, | |||
$guid_two | |||
) |
Create a relationship between two entities.
E.g. friendship, group membership, site membership.
This function lets you make the statement "$guid_one is a $relationship of $guid_two". In the statement, $guid_one is the subject of the relationship, $guid_two is the target, and $relationship is the type.
int | $guid_one | GUID of the subject entity of the relationship |
string | $relationship | Type of the relationship |
int | $guid_two | GUID of the target entity of the relationship |
Definition at line 95 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::check | ( | $guid_one, | |
$relationship, | |||
$guid_two | |||
) |
Check if a relationship exists between two entities.
If so, the relationship object is returned.
This function lets you ask "Is $guid_one a $relationship of $guid_two?"
int | $guid_one | GUID of the subject entity of the relationship |
string | $relationship | Type of the relationship |
int | $guid_two | GUID of the target entity of the relationship |
Definition at line 145 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::delete | ( | $id | ) |
Delete a relationship by its ID.
int | $id | The relationship ID |
Definition at line 68 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::get | ( | $id | ) |
Get a relationship by its ID.
int | $id | The relationship ID |
Definition at line 36 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::getAll | ( | $guid, | |
$inverse_relationship = false |
|||
) |
Get all the relationships for a given GUID.
int | $guid | GUID of the subject or target entity (see $inverse) |
bool | $inverse_relationship | Is $guid the target of the deleted relationships? By default $guid is the subject of the relationships. |
Definition at line 261 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::getEntities | ( | $options | ) |
Return entities matching a given query joining against a relationship.
Also accepts all options available to elgg_get_entities() and elgg_get_entities_from_metadata().
To ask for entities that do not have a particular relationship to an entity, use a custom where clause like the following:
$options['wheres'][] = "NOT EXISTS ( SELECT 1 FROM {$db_prefix}entity_relationships WHERE guid_one = e.guid AND relationship = '$relationship' )";
array | $options | Array in format: |
relationship => null|STR Type of the relationship
relationship_guid => null|INT GUID of the subject or target entity
inverse_relationship => false|BOOL Is relationship_guid is the target entity of the relationship? By default, relationship_guid is the subject.
relationship_join_on => null|STR How the entities relate: guid (default), container_guid, or owner_guid Add in Elgg 1.9.0. Examples using the relationship 'friend':
relationship_created_time_lower => null|INT Relationship created time lower boundary in epoch time
relationship_created_time_upper => null|INT Relationship created time upper boundary in epoch time
Definition at line 311 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::getEntitiesFromCount | ( | array | $options = array() | ) |
Gets the number of entities by a the number of entities related to them in a particular way.
This is a good way to get out the users with the most friends, or the groups with the most members.
array | $options | An options array compatible with elgg_get_entities_from_relationship() |
Definition at line 435 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::getEntityRelationshipWhereSql | ( | $column, | |
$relationship = null , |
|||
$relationship_guid = null , |
|||
$inverse_relationship = false |
|||
) |
Returns SQL appropriate for relationship joins and wheres.
string | $column | Column name the GUID should be checked against. Provide in table.column format. |
string | $relationship | Type of the relationship |
int | $relationship_guid | Entity GUID to check |
bool | $inverse_relationship | Is $relationship_guid the target of the relationship? |
Definition at line 385 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::getRow | ( | $id | ) |
Get a database row from the relationship table.
int | $id | The relationship ID |
Definition at line 53 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::remove | ( | $guid_one, | |
$relationship, | |||
$guid_two | |||
) |
Delete a relationship between two entities.
This function lets you say "$guid_one is no longer a $relationship of $guid_two."
int | $guid_one | GUID of the subject entity of the relationship |
string | $relationship | Type of the relationship |
int | $guid_two | GUID of the target entity of the relationship |
Definition at line 176 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::removeAll | ( | $guid, | |
$relationship = "" , |
|||
$inverse_relationship = false , |
|||
$type = '' |
|||
) |
Removes all relationships originating from a particular entity.
int | $guid | GUID of the subject or target entity (see $inverse) |
string | $relationship | Type of the relationship (optional, default is all relationships) |
bool | $inverse_relationship | Is $guid the target of the deleted relationships? By default, $guid is the subject of the relationships. |
string | $type | The type of entity related to $guid (defaults to all) |
Definition at line 215 of file RelationshipsTable.php.