You are here

function location_load_locations in Location 7.5

Same name and namespace in other branches
  1. 5.3 location.module \location_load_locations()
  2. 5 location.module \location_load_locations()
  3. 6.3 location.module \location_load_locations()
  4. 7.3 location.module \location_load_locations()
  5. 7.4 location.module \location_load_locations()

Load associated locations.

Parameters

$id The identifier to match. (An integer.):

$key The search key for {location_instance} (usually vid or uid.):

Return value

An array of loaded locations.

3 calls to location_load_locations()
location_taxonomy_form_alter in contrib/location_taxonomy/location_taxonomy.module
Implements hook_form_alter().
location_views_handler_filter_proximity::exposed_form in handlers/location_views_handler_filter_proximity.inc
Render our chunk of the exposed filter form when selecting.
location_views_proximity_get_reference_location in ./location.views.inc
Helper function for proximity handlers. Retrieves the coordinates of the location that this field measures distances against.

File

./location.module, line 905
Location module main routines. An implementation of a universal API for location manipulation. Provides functions for postal_code proximity searching, deep-linking into online mapping services. Currently, some options are configured through an…

Code

function location_load_locations($id, $key = 'vid') {
  if (empty($id)) {

    // If the id is 0 or '' (or false), force returning early.
    // Otherwise, this could accidentally load a huge amount of data
    // by accident. 0 and '' are reserved for "not applicable."
    return array();
  }
  $query = db_select('location_instance', 'l');
  $lid_field = $query
    ->addField('l', 'lid');
  $query
    ->condition($key, $id);
  $result = $query
    ->execute();
  $locations = array();
  foreach ($result as $lid) {
    $locations[] = location_load_location($lid->{$lid_field});
  }
  return $locations;
}