You are here

function location_load_locations in Location 6.3

Same name and namespace in other branches
  1. 5.3 location.module \location_load_locations()
  2. 5 location.module \location_load_locations()
  3. 7.5 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.

5 calls to location_load_locations()
location_node_nodeapi in ./location_node.module
Implementation of hook_nodeapi().
location_taxonomy_form_alter in contrib/location_taxonomy/location_taxonomy.module
Implementation of hook_form_alter().
location_user_user in ./location_user.module
Implementation of hook_user().
location_views_handler_filter_proximity::exposed_form in handlers/location_views_handler_filter_proximity.inc
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 857
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();
  }
  if ($key == 'genid') {
    $result = db_query('SELECT lid FROM {location_instance} WHERE ' . db_escape_table($key) . " = '%s' ORDER BY lid", $id);
  }
  else {
    $result = db_query('SELECT lid FROM {location_instance} WHERE ' . db_escape_table($key) . ' = %d ORDER BY lid', $id);
  }
  $locations = array();
  while ($lid = db_fetch_object($result)) {
    $locations[] = location_load_location($lid->lid);
  }
  return $locations;
}