You are here

function _hashtags_index_get_entity_tags in Hashtags 7

Return a array(name => tid) list of entity hashtags (without comments related)

Parameters

int $entity_id:

string $type:

Return value

array (name => tid)

1 call to _hashtags_index_get_entity_tags()
hashtags_entity_presave in ./hashtags.module
Implementation of hook_entity_presave().

File

./hashtags.module, line 531

Code

function _hashtags_index_get_entity_tags($entity_id, $type) {
  $result = db_query('SELECT hi.tid, td.name
    FROM {hashtags_index} hi
    INNER JOIN {taxonomy_term_data} td ON hi.tid = td.tid
    WHERE hi.entity_id = :entity_id
    AND hi.type = :type
    AND hi.comment_id IS NULL', array(
    ':entity_id' => $entity_id,
    ':type' => $type,
  ));
  $tags = array();
  foreach ($result as $data) {
    $tags[$data->name] = $data->tid;
  }
  return $tags;
}