You are here

function getlocations_get_entity_info_from_glid in Get Locations 7.2

Function to return entity information from a supplied location identifier

Parameters

int $glid location identifier:

Return value

array with keys 'entity_type', 'bundle', 'entity_id'

3 calls to getlocations_get_entity_info_from_glid()
getlocations_fields_load_location in modules/getlocations_fields/getlocations_fields.module
getlocations_get_path_from_lid in ./getlocations.module
Function to return url from a supplied location identifier
getlocations_get_type_from_lid in ./getlocations.module
Function to get type for getlocations_fields and location modules only

File

./getlocations.module, line 1507
getlocations.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_get_entity_info_from_glid($glid) {
  if (is_numeric($glid) && $glid) {
    if (module_exists('getlocations_fields')) {
      $query = db_select('getlocations_fields', 'g')
        ->fields('g', array(
        'field_name',
      ))
        ->condition('g.glid', $glid);
      $row = $query
        ->execute()
        ->fetchAssoc();
      $field_name = $row['field_name'];
      $table = 'field_data_' . $field_name;
      if (db_table_exists($table)) {
        $col = $field_name . '_glid';
        $query = db_select($table, 't')
          ->fields('t', array(
          'entity_type',
          'bundle',
          'entity_id',
        ))
          ->condition('t.' . $col, $glid);
        $row = $query
          ->execute()
          ->fetchAssoc();
        return $row;
      }
    }
  }
}