Elgg  Version master
Public Member Functions | Public 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 (protected AccessCache $access_cache, protected MetadataCache $metadata_cache, protected Database $db, protected Events $events, protected 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...
 
 getIDsByName (int $entity_guid, string $name)
 Returns ID(s) of metadata with a particular name attached to an entity. More...
 

Public Attributes

const TABLE_NAME = 'metadata'
 
const DEFAULT_JOIN_ALIAS = 'n_table'
 

Detailed Description

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

Definition at line 20 of file MetadataTable.php.

Constructor & Destructor Documentation

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

Constructor.

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

Definition at line 37 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 190 of file MetadataTable.php.

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

Deletes metadata using its ID.

Parameters
\ElggMetadata$metadataMetadata
Returns
bool

Definition at line 157 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 362 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 138 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 316 of file MetadataTable.php.

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

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 422 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 334 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 60 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 275 of file MetadataTable.php.

Member Data Documentation

const Elgg\Database\MetadataTable::DEFAULT_JOIN_ALIAS = 'n_table'

Definition at line 26 of file MetadataTable.php.

const Elgg\Database\MetadataTable::TABLE_NAME = 'metadata'

Definition at line 24 of file MetadataTable.php.


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