Skip to content

Commit

Permalink
Search on more data, return more detailed name.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Nov 5, 2016
1 parent 9827b9c commit 73ed419
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions framework/Service_Weather/lib/Horde/Service/Weather/Metar.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,18 @@ public function autocompleteLocation($search)
return array();
}

$sql = 'SELECT icao, name FROM ' . $this->_tableName . ' WHERE '
. 'name LIKE ? OR icao LIKE ?';
$sql = 'SELECT icao, name, state, municipality, country FROM ' . $this->_tableName . ' WHERE '
. 'name LIKE ? OR icao LIKE ? OR state LIKE ? OR municipality LIKE ?';
try {
$rows = $this->_db->select($sql, array($search . '%', $search . '%'));
$rows = $this->_db->select($sql, array_fill(0, 4, $search . '%'));
} catch (Horde_Db_Exception $e) {
throw new Horde_Service_Weather_Exception($e);
}

$results = array();
foreach ($rows as $row) {
$obj = new stdClass();
$obj->name = $row['name'];
$obj->name = sprintf('%s (%s, %s, %s)', $row['name'], $row['municipality'], $row['state'], $row['country']);
$obj->code = $row['icao'];
$results[] = $obj;
}
Expand All @@ -308,7 +308,7 @@ protected function _getLocations()
if (empty($this->_db)) {
return array();
}
$sql = 'SELECT icao, name, country FROM ' . $this->_tableName . ' ORDER BY country';
$sql = 'SELECT icao, name, state, municipality, country FROM ' . $this->_tableName . ' ORDER BY country';
try {
return $this->_db->selectAll($sql);
} catch (Horde_Exception $e) {
Expand Down

0 comments on commit 73ed419

Please sign in to comment.