You are here

function getlocations_get_nid_from_lid in Get Locations 7.2

Same name and namespace in other branches
  1. 6.2 getlocations.module \getlocations_get_nid_from_lid()
  2. 6 getlocations.module \getlocations_get_nid_from_lid()
  3. 7 getlocations.module \getlocations_get_nid_from_lid()

Function to get nid from location_instance table.

Parameters

int $lid:

Return value

Returns nid.

1 call to getlocations_get_nid_from_lid()
getlocations_getinfo in ./getlocations.module

File

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

Code

function getlocations_get_nid_from_lid($lid) {
  if (is_numeric($lid) && $lid) {
    if (module_exists('location') && (module_exists('location_cck') || module_exists('location_node'))) {
      $query = db_select('location_instance', 'i')
        ->fields('i', array(
        'nid',
      ))
        ->condition('i.lid', $lid);
      $row = $query
        ->execute()
        ->fetchAssoc();
      return isset($row['nid']) && $row['nid'] ? $row['nid'] : FALSE;
    }
  }
  return FALSE;
}