function location_load_locations in Location 5.3
Same name and namespace in other branches
- 5 location.module \location_load_locations()
- 6.3 location.module \location_load_locations()
- 7.5 location.module \location_load_locations()
- 7.3 location.module \location_load_locations()
- 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.
2 calls to location_load_locations()
- location_node_nodeapi in ./
location_node.module - Implementation of hook_nodeapi().
- location_user_user in ./
location_user.module - Implementation of hook_user().
File
- ./
location.module, line 717 - 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'", $id);
}
else {
$result = db_query('SELECT lid FROM {location_instance} WHERE ' . db_escape_table($key) . ' = %d', $id);
}
$locations = array();
while ($lid = db_fetch_object($result)) {
$locations[] = location_load_location($lid->lid);
}
return $locations;
}