Elgg  Version 5.1
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Elgg\Database\MetadataTable Class Reference

This class interfaces with the database to perform CRUD operations on metadata. More...

Public Member Functions

 __construct (MetadataCache $metadata_cache, Database $db, Events $events, EntityTable $entityTable)
 Constructor. More...
 
 getTags (array $options=[])
 Get popular tags and their frequencies. More...
 
 get (int $id)
 Get a specific metadata object by its id. More...
 
 delete (\ElggMetadata $metadata)
 Deletes metadata using its ID. More...
 
 create (\ElggMetadata $metadata, bool $allow_multiple=false)
 Create a new metadata object, or update an existing one (if multiple is allowed) More...
 
 update (\ElggMetadata $metadata)
 Update a specific piece of metadata. More...
 
 getAll (array $options=[])
 Returns metadata. More...
 
 getRowsForGuids (array $guids)
 Returns metadata rows. More...
 
 deleteAll (array $options)
 Deletes metadata based on $options. More...
 

Public Attributes

const MYSQL_TEXT_BYTE_LIMIT = 65535
 

Protected Member Functions

 getIDsByName (int $entity_guid, string $name)
 Returns ID(s) of metadata with a particular name attached to an entity. More...
 

Protected Attributes

MetadataCache $metadata_cache
 
Database $db
 
Events $events
 
EntityTable $entityTable
 

Detailed Description

This class interfaces with the database to perform CRUD operations on metadata.

Definition at line 19 of file MetadataTable.php.

Constructor & Destructor Documentation

Elgg\Database\MetadataTable::__construct ( MetadataCache  $metadata_cache,
Database  $db,
Events  $events,
EntityTable  $entityTable 
)

Constructor.

Parameters
MetadataCache$metadata_cacheA cache for this table
Database$dbThe Elgg database
Events$eventsThe events registry
EntityTable$entityTableThe EntityTable database wrapper

Definition at line 41 of file MetadataTable.php.

Member Function Documentation

Elgg\Database\MetadataTable::create ( \ElggMetadata  $metadata,
bool  $allow_multiple = false 
)

Create a new metadata object, or update an existing one (if multiple is allowed)

Metadata can be an array by setting allow_multiple to true, but it is an indexed array with no control over the indexing

Parameters
\ElggMetadata$metadataMetadata
bool$allow_multipleAllow multiple values for one key. Default is false
Returns
int|false id of metadata or false if failure
Exceptions
LogicException

Definition at line 197 of file MetadataTable.php.

Elgg\Database\MetadataTable::delete ( \ElggMetadata  $metadata)

Deletes metadata using its ID.

Parameters
\ElggMetadata$metadataMetadata
Returns
bool

Definition at line 164 of file MetadataTable.php.

Elgg\Database\MetadataTable::deleteAll ( array  $options)

Deletes metadata based on $options.

Warning
Unlike elgg_get_metadata() this will not accept an empty options array! This requires at least one constraint: metadata_name(s), metadata_value(s), or guid(s) must be set.
See also
elgg_get_metadata()
elgg_get_entities()
Parameters
array$optionsOptions
Returns
bool
Exceptions
InvalidArgumentException

Definition at line 377 of file MetadataTable.php.

Elgg\Database\MetadataTable::get ( int  $id)

Get a specific metadata object by its id.

See also
MetadataTable::getAll()
Parameters
int$idThe id of the metadata object being retrieved.
Returns
|null

Definition at line 145 of file MetadataTable.php.

Elgg\Database\MetadataTable::getAll ( array  $options = [])

Returns metadata.

Accepts all elgg_get_entities() options for entity restraints.

See also
elgg_get_entities()
Parameters
array$optionsOptions
Returns
[]|mixed

Definition at line 331 of file MetadataTable.php.

Elgg\Database\MetadataTable::getIDsByName ( int  $entity_guid,
string  $name 
)
protected

Returns ID(s) of metadata with a particular name attached to an entity.

Parameters
int$entity_guidEntity guid
string$nameMetadata name
Returns
int[]|int|null

Definition at line 432 of file MetadataTable.php.

Elgg\Database\MetadataTable::getRowsForGuids ( array  $guids)

Returns metadata rows.

Used internally for metadata preloading

Parameters
array$guidsArray of guids to fetch metadata rows for
Returns
[]

Definition at line 349 of file MetadataTable.php.

Elgg\Database\MetadataTable::getTags ( array  $options = [])

Get popular tags and their frequencies.

Accepts all options supported by {

See also
elgg_get_metadata()}

Returns an array of objects that include "tag" and "total" properties

Parameters
array$optionsOptions

int $threshold Minimum number of tag occurrences string[] $tag_names tag names to include in search

Returns
[]|false

Definition at line 67 of file MetadataTable.php.

Elgg\Database\MetadataTable::update ( \ElggMetadata  $metadata)

Update a specific piece of metadata.

Parameters
\ElggMetadata$metadataUpdated metadata
Returns
bool

Definition at line 286 of file MetadataTable.php.

Member Data Documentation

Database Elgg\Database\MetadataTable::$db
protected

Definition at line 27 of file MetadataTable.php.

EntityTable Elgg\Database\MetadataTable::$entityTable
protected

Definition at line 31 of file MetadataTable.php.

Events Elgg\Database\MetadataTable::$events
protected

Definition at line 29 of file MetadataTable.php.

MetadataCache Elgg\Database\MetadataTable::$metadata_cache
protected

Definition at line 25 of file MetadataTable.php.

const Elgg\Database\MetadataTable::MYSQL_TEXT_BYTE_LIMIT = 65535

Definition at line 23 of file MetadataTable.php.


The documentation for this class was generated from the following file: