Elgg  Version 3.0
Public Member Functions | Public Attributes | 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)
 Constructor. More...
 
 registerTagName ($name)
 Registers a metadata name as containing tags for an entity. More...
 
 unregisterTagName ($name)
 Unregisters a metadata tag name. More...
 
 getTagNames ()
 Returns an array of valid metadata names for tags. More...
 
 getTags (array $options=[])
 Get popular tags and their frequencies. More...
 
 get ($id)
 Get a specific metadata object by its id. More...
 
 delete (ElggMetadata $metadata)
 Deletes metadata using its ID. More...
 
 create (ElggMetadata $metadata, $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 ($entity_guid, $name)
 Returns ID(s) of metadata with a particular name attached to an entity. More...
 

Public Attributes

const MYSQL_TEXT_BYTE_LIMIT = 65535
 

Protected Attributes

 $metadata_cache
 
 $db
 
 $events
 
 $tag_names = []
 

Detailed Description

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

WARNING: API IN FLUX. DO NOT USE DIRECTLY.

Definition at line 20 of file MetadataTable.php.

Constructor & Destructor Documentation

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

Constructor.

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

Definition at line 53 of file MetadataTable.php.

Member Function Documentation

Elgg\Database\MetadataTable::create ( ElggMetadata  $metadata,
  $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

Definition at line 263 of file MetadataTable.php.

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

Deletes metadata using its ID.

Parameters
ElggMetadata$metadataMetadata
Returns
bool
Exceptions

Definition at line 230 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|null true on success, false on failure, null if no metadata to delete.

Definition at line 434 of file MetadataTable.php.

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

Get a specific metadata object by its id.

See also
MetadataTable::getAll()
Parameters
int$idThe id of the metadata object being retrieved.
Returns
ElggMetadata|false false if not found
Exceptions

Definition at line 206 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
ElggMetadata[]|mixed

Definition at line 389 of file MetadataTable.php.

Elgg\Database\MetadataTable::getIdsByName (   $entity_guid,
  $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 473 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 408 of file MetadataTable.php.

Elgg\Database\MetadataTable::getTagNames ( )

Returns an array of valid metadata names for tags.

Returns
string[]

Definition at line 101 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 Names of registered tag names to include in search

Returns
[]|false
Exceptions

Definition at line 124 of file MetadataTable.php.

Elgg\Database\MetadataTable::registerTagName (   $name)

Registers a metadata name as containing tags for an entity.

Parameters
string$nameTag name
Returns
bool

Definition at line 70 of file MetadataTable.php.

Elgg\Database\MetadataTable::unregisterTagName (   $name)

Unregisters a metadata tag name.

Parameters
string$nameTag name
Returns
bool

Definition at line 85 of file MetadataTable.php.

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

Update a specific piece of metadata.

Parameters
ElggMetadata$metadataUpdated metadata
Returns
bool
Exceptions

Definition at line 348 of file MetadataTable.php.

Member Data Documentation

Elgg\Database\MetadataTable::$db
protected

Definition at line 32 of file MetadataTable.php.

Elgg\Database\MetadataTable::$events
protected

Definition at line 37 of file MetadataTable.php.

Elgg\Database\MetadataTable::$metadata_cache
protected

Definition at line 27 of file MetadataTable.php.

Elgg\Database\MetadataTable::$tag_names = []
protected

Definition at line 42 of file MetadataTable.php.

const Elgg\Database\MetadataTable::MYSQL_TEXT_BYTE_LIMIT = 65535

Definition at line 44 of file MetadataTable.php.


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