/[drupal]/contributions/modules/location/supported/location.us.inc
ViewVC logotype

Diff of /contributions/modules/location/supported/location.us.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.24, Wed Feb 4 23:21:56 2009 UTC revision 1.25, Mon Aug 31 22:09:35 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: location.us.inc,v 1.23 2008/08/21 16:18:05 bdragon Exp $  // $Id: location.us.inc,v 1.24 2009/02/04 23:21:56 bdragon Exp $
3    
4  /**  /**
5   * Returns a lat/lon pair of the approximate center of the given postal code in the given country   * Returns a lat/lon pair of the approximate center of the given postal code in the given country
# Line 23  function location_latlon_rough_us($locat Line 23  function location_latlon_rough_us($locat
23      return NULL;      return NULL;
24    }    }
25    
26    $result = db_query("SELECT latitude, longitude FROM {zipcodes} WHERE country = '%s' AND zip = '%s'", $location['country'], substr(str_pad($location['postal_code'], 5, '0', STR_PAD_LEFT), 0, 5));    $result = db_query("SELECT latitude, longitude FROM {zipcodes} WHERE country = :country AND zip = :zip", array(':country' => $location['country'], ':zip' => substr(str_pad($location['postal_code'], 5, '0', STR_PAD_LEFT), 0, 5)));
27      if (($row = $result->fetchObject()) !== FALSE) {
   if ($row = db_fetch_object($result)) {  
28      return array('lat' => $row->latitude, 'lon' => $row->longitude);      return array('lat' => $row->latitude, 'lon' => $row->longitude);
29    }    }
30    else {    else {
# Line 58  function location_get_postalcode_data_us Line 57  function location_get_postalcode_data_us
57    }    }
58    
59    // Now we pad the thing and query.    // Now we pad the thing and query.
60    $res = db_query("SELECT * FROM {zipcodes} where country = '%s' AND zip = '%s'", $location['country'], str_pad($location['postal_code'], 5, "0", STR_PAD_LEFT));    $res = db_query("SELECT * FROM {zipcodes} where country = :country AND zip = :zip", array(':country' => $location['country'], ':zip' => str_pad($location['postal_code'], 5, "0", STR_PAD_LEFT)));
61    if ($row = db_fetch_object($res)) {    if (($row = $result->fetchObject()) !== FALSE) {
62      return array('lat' => $row->latitude, 'lon' => $row->longitude, 'city' => $row->city, 'province' => $row->state, 'country' => $row->country);      return array('lat' => $row->latitude, 'lon' => $row->longitude, 'city' => $row->city, 'province' => $row->state, 'country' => $row->country);
63    }    }
64    else {    else {

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.2