Elgg
Version 2.3
|
Public Member Functions | |
__construct (Conf $config, Database $db, EntityCache $entity_cache, MetadataCache $metadata_cache, SubtypeTable $subtype_table, EventsService $events, ElggSession $session, Translator $translator, Logger $logger) | |
Constructor. More... | |
getRow ($guid, $user_guid=null) | |
Returns a database row from the entities table. More... | |
insertRow (stdClass $row) | |
Adds a new row to the entity table. More... | |
updateRow ($guid, stdClass $row) | |
Update entity table row. More... | |
rowToElggStar ($row) | |
Create an Elgg* object from a given entity row. More... | |
get ($guid, $type= '') | |
Loads and returns an entity object from a guid. More... | |
exists ($guid) | |
Does an entity exist? More... | |
enable ($guid, $recursive=true) | |
Enable an entity. More... | |
getEntities (array $options=array()) | |
Returns an array of entities with optional filtering. More... | |
fetchFromSql ($sql,\ElggBatch $batch=null) | |
Return entities from an SQL query generated by elgg_get_entities. More... | |
getEntityTypeSubtypeWhereSql ($table, $types=[], $subtypes=[], $pairs=[]) | |
Returns SQL where clause for type and subtype on main entity table. More... | |
getGuidBasedWhereSql ($column, $guids) | |
Returns SQL where clause for owner and containers. More... | |
getEntityTimeWhereSql ($table, $time_created_upper=null, $time_created_lower=null, $time_updated_upper=null, $time_updated_lower=null) | |
Returns SQL where clause for entity time limits. More... | |
getEntitiesFromAttributes (array $options=array()) | |
Gets entities based upon attributes in secondary tables. More... | |
getEntityAttributeWhereSql (array $options=array()) | |
Get the join and where clauses for working with entity attributes. More... | |
getDates ($type= '', $subtype= '', $container_guid=0, $site_guid=0, $order_by= 'time_created') | |
Returns a list of months in which entities were updated or created. More... | |
updateLastAction (ElggEntity $entity, $posted=null) | |
Update the last_action column in the entities table for $guid. More... | |
getUserForPermissionsCheck ($guid=0) | |
Get a user by GUID even if the entity is hidden or disabled. More... | |
disableEntities ($owner_guid) | |
Disables all entities owned and contained by a user (or another entity) More... | |
Protected Member Functions | |
getFromCache ($guid) | |
Get an entity from the in-memory or memcache caches. More... | |
autoJoinTables (array $options) | |
Decorate getEntities() options in order to auto-join secondary tables where it's safe to do so. More... | |
Protected Attributes | |
$config | |
$db | |
$table | |
$subtype_table | |
$entity_cache | |
$entity_preloader | |
$metadata_cache | |
$events | |
$session | |
$translator | |
$logger | |
Definition at line 39 of file EntityTable.php.
Elgg\Database\EntityTable::__construct | ( | Conf | $config, |
Database | $db, | ||
EntityCache | $entity_cache, | ||
MetadataCache | $metadata_cache, | ||
SubtypeTable | $subtype_table, | ||
EventsService | $events, | ||
ElggSession | $session, | ||
Translator | $translator, | ||
Logger | $logger | ||
) |
Constructor.
Conf | $config | Config |
Database | $db | Database |
EntityCache | $entity_cache | Entity cache |
MetadataCache | $metadata_cache | Metadata cache |
SubtypeTable | $subtype_table | Subtype table |
EventsService | $events | Events service |
ElggSession | $session | Session |
Translator | $translator | Translator |
Logger | $logger | Logger |
Definition at line 111 of file EntityTable.php.
|
protected |
Decorate getEntities() options in order to auto-join secondary tables where it's safe to do so.
array | $options | Options array in getEntities() after normalization |
Definition at line 733 of file EntityTable.php.
Elgg\Database\EntityTable::disableEntities | ( | $owner_guid | ) |
Disables all entities owned and contained by a user (or another entity)
int | $owner_guid | The owner GUID |
Definition at line 1489 of file EntityTable.php.
Elgg\Database\EntityTable::enable | ( | $guid, | |
$recursive = true |
|||
) |
Enable an entity.
int | $guid | GUID of entity to enable |
bool | $recursive | Recursively enable all entities disabled with the entity? |
Definition at line 388 of file EntityTable.php.
Elgg\Database\EntityTable::exists | ( | $guid | ) |
Does an entity exist?
This function checks for the existence of an entity independent of access permissions. It is useful for situations when a user cannot access an entity and it must be determined whether entity has been deleted or the access level has changed.
int | $guid | The GUID of the entity |
Definition at line 367 of file EntityTable.php.
Elgg\Database\EntityTable::fetchFromSql | ( | $sql, | |
\ElggBatch | $batch = null |
||
) |
Return entities from an SQL query generated by elgg_get_entities.
private
string | $sql | |
ElggBatch | $batch |
LogicException |
Definition at line 789 of file EntityTable.php.
Elgg\Database\EntityTable::get | ( | $guid, | |
$type = '' |
|||
) |
Loads and returns an entity object from a guid.
int | $guid | The GUID of the entity |
string | $type | The type of the entity. If given, even an existing entity with the given GUID will not be returned unless its type matches. |
ClassException | |
InstallationException |
Definition at line 323 of file EntityTable.php.
Elgg\Database\EntityTable::getDates | ( | $type = '' , |
|
$subtype = '' , |
|||
$container_guid = 0 , |
|||
$site_guid = 0 , |
|||
$order_by = 'time_created' |
|||
) |
Returns a list of months in which entities were updated or created.
Use this to generate a list of archives by month for when entities were added or updated.
string | $type | The type of entity |
string | $subtype | The subtype of entity |
int | $container_guid | The container GUID that the entities belong to |
int | $site_guid | The site GUID |
string | $order_by | Order_by SQL order by clause |
Definition at line 1327 of file EntityTable.php.
Elgg\Database\EntityTable::getEntities | ( | array | $options = array() | ) |
Returns an array of entities with optional filtering.
Entities are the basic unit of storage in Elgg. This function provides the simplest way to get an array of entities. There are many options available that can be passed to filter what sorts of entities are returned.
To output formatted strings of entities, use elgg_list_entities() and its cousins.
Plural arguments can be written as singular if only specifying a single element. ('type' => 'object' vs 'types' => array('object')).
array | $options | Array in format: types => null|STR entity type (type IN ('type1', 'type2') Joined with subtypes by AND. See below) subtypes => null|STR entity subtype (SQL: subtype IN ('subtype1', 'subtype2)) Use ELGG_ENTITIES_NO_VALUE to match the default subtype. Use ELGG_ENTITIES_ANY_VALUE to match any subtype. type_subtype_pairs => null|ARR (array('type' => 'subtype')) array( 'object' => array('blog', 'file'), // All objects with subtype of 'blog' or 'file' 'user' => ELGG_ENTITY_ANY_VALUE, // All users irrespective of subtype ); guids => null|ARR Array of entity guids owner_guids => null|ARR Array of owner guids container_guids => null|ARR Array of container_guids site_guids => null (current_site)|ARR Array of site_guid order_by => null (time_created desc)|STR SQL order by clause |
reverse_order_by => BOOL Reverse the default order by clause
limit => null (10)|INT SQL limit clause (0 means no limit)
offset => null (0)|INT SQL offset clause
created_time_lower => null|INT Created time lower boundary in epoch time
created_time_upper => null|INT Created time upper boundary in epoch time
modified_time_lower => null|INT Modified time lower boundary in epoch time
modified_time_upper => null|INT Modified time upper boundary in epoch time
count => true|false return a count instead of entities
wheres => array() Additional where clauses to AND together
joins => array() Additional joins
preload_owners => bool (false) If set to true, this function will preload all the owners of the returned entities resulting in better performance if those owners need to be displayed
preload_containers => bool (false) If set to true, this function will preload all the containers of the returned entities resulting in better performance if those containers need to be displayed
callback => string A callback function to pass each row through distinct => bool (true) If set to false, Elgg will drop the DISTINCT clause from the MySQL query, which will improve performance in some situations. Avoid setting this option without a full understanding of the underlying SQL query Elgg creates.
batch => bool (false) If set to true, an Elgg object will be returned instead of an array. Since 2.3
batch_inc_offset => bool (true) If "batch" is used, this tells the batch to increment the offset on each fetch. This must be set to false if you delete the batched results.
batch_size => int (25) If "batch" is used, this is the number of entities/rows to pull in before requesting more.
Definition at line 502 of file EntityTable.php.
Elgg\Database\EntityTable::getEntitiesFromAttributes | ( | array | $options = array() | ) |
Gets entities based upon attributes in secondary tables.
Also accepts all options available to elgg_get_entities(), elgg_get_entities_from_metadata(), and elgg_get_entities_from_relationship().
array | $options | Array in format: attribute_name_value_pairs => ARR ( 'name' => 'name', 'value' => 'value', 'operand' => '=', (optional) 'case_sensitive' => false (optional) ) If multiple values are sent via an array ('value' => array('value1', 'value2') the pair's operand will be forced to "IN". attribute_name_value_pairs_operator => null|STR The operator to use for combining (name = value) OPERATOR (name = value); default is AND |
InvalidArgumentException |
Definition at line 1168 of file EntityTable.php.
Elgg\Database\EntityTable::getEntityAttributeWhereSql | ( | array | $options = array() | ) |
Get the join and where clauses for working with entity attributes.
InvalidArgumentException |
Definition at line 1211 of file EntityTable.php.
Elgg\Database\EntityTable::getEntityTimeWhereSql | ( | $table, | |
$time_created_upper = null , |
|||
$time_created_lower = null , |
|||
$time_updated_upper = null , |
|||
$time_updated_lower = null |
|||
) |
Returns SQL where clause for entity time limits.
string | $table | Entity table prefix as defined in SELECT...FROM entities $table |
null | int | $time_created_upper | Time created upper limit |
null | int | $time_created_lower | Time created lower limit |
null | int | $time_updated_upper | Time updated upper limit |
null | int | $time_updated_lower | Time updated lower limit |
Definition at line 1107 of file EntityTable.php.
Elgg\Database\EntityTable::getEntityTypeSubtypeWhereSql | ( | $table, | |
$types = [] , |
|||
$subtypes = [] , |
|||
$pairs = [] |
|||
) |
Returns SQL where clause for type and subtype on main entity table.
string | $table | Entity table prefix as defined in SELECT...FROM entities $table |
array | $types | Array of types |
array | $subtypes | Array of subtypes |
array | $pairs | Array of pairs of types and subtypes |
Definition at line 892 of file EntityTable.php.
|
protected |
Get an entity from the in-memory or memcache caches.
int | $guid | GUID |
Definition at line 291 of file EntityTable.php.
Elgg\Database\EntityTable::getGuidBasedWhereSql | ( | $column, | |
$guids | |||
) |
Returns SQL where clause for owner and containers.
string | $column | Column name the guids should be checked against. Usually best to provide in table.column format. |
null | array | $guids | Array of GUIDs. |
Definition at line 1059 of file EntityTable.php.
Elgg\Database\EntityTable::getRow | ( | $guid, | |
$user_guid = null |
|||
) |
Returns a database row from the entities table.
Use get_entity() to return the fully loaded entity.
int | $guid | The GUID of the object to extract |
int | $user_guid | GUID of the user accessing the row Defaults to logged in user if null Builds an access query for a logged out user if 0 |
Definition at line 151 of file EntityTable.php.
Elgg\Database\EntityTable::getUserForPermissionsCheck | ( | $guid = 0 | ) |
Get a user by GUID even if the entity is hidden or disabled.
int | $guid | User GUID. Default is logged in user |
UserFetchFailureException | private |
Definition at line 1457 of file EntityTable.php.
Elgg\Database\EntityTable::insertRow | ( | stdClass | $row | ) |
Adds a new row to the entity table.
stdClass | $row | Entity base information |
Definition at line 178 of file EntityTable.php.
Elgg\Database\EntityTable::rowToElggStar | ( | $row | ) |
Create an Elgg* object from a given entity row.
Handles loading all tables into the correct class.
private
stdClass | $row | The row of the entry in the entities table. |
ClassException | |
InstallationException |
Definition at line 246 of file EntityTable.php.
Elgg\Database\EntityTable::updateLastAction | ( | ElggEntity | $entity, |
$posted = null |
|||
) |
Update the last_action column in the entities table for $guid.
ElggEntity | $entity | Entity annotation|relationship action carried out on |
int | $posted | Timestamp of last action |
Definition at line 1420 of file EntityTable.php.
Elgg\Database\EntityTable::updateRow | ( | $guid, | |
stdClass | $row | ||
) |
Update entity table row.
int | $guid | Entity guid |
stdClass | $row | Updated data |
Definition at line 207 of file EntityTable.php.
|
protected |
Definition at line 46 of file EntityTable.php.
|
protected |
Definition at line 51 of file EntityTable.php.
|
protected |
Definition at line 66 of file EntityTable.php.
|
protected |
Definition at line 71 of file EntityTable.php.
|
protected |
Definition at line 81 of file EntityTable.php.
|
protected |
Definition at line 96 of file EntityTable.php.
|
protected |
Definition at line 76 of file EntityTable.php.
|
protected |
Definition at line 86 of file EntityTable.php.
|
protected |
Definition at line 61 of file EntityTable.php.
|
protected |
Definition at line 56 of file EntityTable.php.
|
protected |
Definition at line 91 of file EntityTable.php.