Elgg
Version 4.3
|
Relationships table database service. More...
Public Member Functions | |
__construct (Database $db, EntityTable $entities, MetadataTable $metadata, EventsService $events) | |
Constructor. More... | |
get (int $id) | |
Get a relationship by its ID. More... | |
delete (int $id, bool $call_event=true) | |
Delete a relationship by its ID. More... | |
add (int $guid_one, string $relationship, int $guid_two, bool $return_id=false) | |
Create a relationship between two entities. More... | |
check (int $guid_one, string $relationship, int $guid_two) | |
Check if a relationship exists between two entities. More... | |
remove (int $guid_one, string $relationship, int $guid_two) | |
Delete a relationship between two entities. More... | |
removeAll ($guid, $relationship= '', $inverse_relationship=false, $type= '', bool $trigger_events=true) | |
Removes all relationships originating from a particular entity. More... | |
getAll ($guid, $inverse_relationship=false) | |
Get all the relationships for a given GUID. More... | |
getEntitiesFromCount (array $options=[]) | |
Gets the number of entities by a the number of entities related to them in a particular way. More... | |
rowToElggRelationship ($row) | |
Convert a database row to a new . More... | |
Public Attributes | |
const | RELATIONSHIP_COLUMN_LENGTH = 255 |
Protected Member Functions | |
removeAllWithoutEvents ($guid, $relationship= '', $inverse_relationship=false, $type= '') | |
Removes all relationships originating from a particular entity. More... | |
removeAllWithEvents ($guid, $relationship= '', $inverse_relationship=false, $type= '') | |
Removes all relationships originating from a particular entity. More... | |
Protected Attributes | |
$db | |
$entities | |
$metadata | |
$events | |
Relationships table database service.
Definition at line 21 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::__construct | ( | Database | $db, |
EntityTable | $entities, | ||
MetadataTable | $metadata, | ||
EventsService | $events | ||
) |
Constructor.
Database | $db | Elgg Database |
EntityTable | $entities | Entity table |
MetadataTable | $metadata | Metadata table |
EventsService | $events | Events service |
Definition at line 58 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::add | ( | int | $guid_one, |
string | $relationship, | ||
int | $guid_two, | ||
bool | $return_id = false |
||
) |
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 |
bool | $return_id | Return the ID instead of bool? |
InvalidArgumentException |
Definition at line 118 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::check | ( | int | $guid_one, |
string | $relationship, | ||
int | $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 179 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::delete | ( | int | $id, |
bool | $call_event = true |
||
) |
Delete a relationship by its ID.
int | $id | Relationship ID |
bool | $call_event | Call the delete event before deleting |
Definition at line 88 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::get | ( | int | $id | ) |
Get a relationship by its ID.
int | $id | The relationship ID |
Definition at line 72 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 357 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::getEntitiesFromCount | ( | array | $options = [] | ) |
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() |
Definition at line 379 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::remove | ( | int | $guid_one, |
string | $relationship, | ||
int | $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 206 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::removeAll | ( | $guid, | |
$relationship = '' , |
|||
$inverse_relationship = false , |
|||
$type = '' , |
|||
bool | $trigger_events = true |
||
) |
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) |
bool | $trigger_events | Trigger the delete event for each relationship (default: true) |
Definition at line 227 of file RelationshipsTable.php.
|
protected |
Removes all relationships originating from a particular entity.
The does trigger the delete event for each relationship
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 292 of file RelationshipsTable.php.
|
protected |
Removes all relationships originating from a particular entity.
This doesn't trigger the delete event for each relationship
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 249 of file RelationshipsTable.php.
Elgg\Database\RelationshipsTable::rowToElggRelationship | ( | $row | ) |
Convert a database row to a new .
\stdClass | $row | Database row from the relationship table |
Definition at line 394 of file RelationshipsTable.php.
|
protected |
Definition at line 33 of file RelationshipsTable.php.
|
protected |
Definition at line 38 of file RelationshipsTable.php.
|
protected |
Definition at line 48 of file RelationshipsTable.php.
|
protected |
Definition at line 43 of file RelationshipsTable.php.
const Elgg\Database\RelationshipsTable::RELATIONSHIP_COLUMN_LENGTH = 255 |
Definition at line 28 of file RelationshipsTable.php.