cvs: pear /Services_Weather/Weather Metar.php

From: Date: Tue, 08 Nov 2005 10:57:37 +0000
Subject: cvs: pear /Services_Weather/Weather Metar.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-36151@lists.php.net to get a copy of this message
eru Tue Nov 8 05:57:37 2005 EDT Modified files: /pear/Services_Weather/Weather Metar.php Log: o Fixed location searching for certain cases http://cvs.php.net/diff.php/pear/Services_Weather/Weather/Metar.php?r1=1.72&r2=1.73&ty=u Index: pear/Services_Weather/Weather/Metar.php diff -u pear/Services_Weather/Weather/Metar.php:1.72 pear/Services_Weather/Weather/Metar.php:1.73 --- pear/Services_Weather/Weather/Metar.php:1.72 Tue Nov 8 05:50:12 2005 +++ pear/Services_Weather/Weather/Metar.php Tue Nov 8 05:57:33 2005 @@ -16,7 +16,7 @@ // | Authors: Alexander Wirtz <alex@pc4p.net> | // +----------------------------------------------------------------------+ // -// $Id: Metar.php,v 1.72 2005/11/08 10:50:12 eru Exp $ +// $Id: Metar.php,v 1.73 2005/11/08 10:57:33 eru Exp $ /** * @package Services_Weather @@ -1278,14 +1278,19 @@ // Try to part search string in name, state and country part // and build where clause from it for the select $location = explode(",", $location); - if (sizeof($location) >= 1) { + if (sizeof($location) == 1) { + $where = "LOWER(name) LIKE '%".strtolower(trim($location[0]))."%'"; + } elseif (sizeof($location) == 2) { $where = "LOWER(name) LIKE '%".strtolower(trim($location[0]))."%'"; - } - if (sizeof($location) == 2) { $where .= " AND LOWER(country) LIKE '%".strtolower(trim($location[1]))."%'"; } elseif (sizeof($location) == 3) { + $where = "LOWER(name) LIKE '%".strtolower(trim($location[0]))."%'"; $where .= " AND LOWER(state) LIKE '%".strtolower(trim($location[1]))."%'"; $where .= " AND LOWER(country) LIKE '%".strtolower(trim($location[2]))."%'"; + } elseif (sizeof($location) == 4) { + $where = "LOWER(name) LIKE '%".strtolower(trim($location[0])).", ".strtolower(trim($location[1]))."%'"; + $where .= " AND LOWER(state) LIKE '%".strtolower(trim($location[2]))."%'"; + $where .= " AND LOWER(country) LIKE '%".strtolower(trim($location[3]))."%'"; } // Create select, locations with ICAO first @@ -1384,13 +1389,15 @@ $locations = array(); while (($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) != null) { $locicao = $row["icao"]; - // First the name of the location - if (!strlen($row["state"])) { - $locname = $row["name"].", ".$row["country"]; - } else { - $locname = $row["name"].", ".$row["state"].", ".$row["country"]; + if ($locicao != "----") { + // First the name of the location + if (!strlen($row["state"])) { + $locname = $row["name"].", ".$row["country"]; + } else { + $locname = $row["name"].", ".$row["state"].", ".$row["country"]; + } + $locations[$locicao] = $locname; } - $locations[$locicao] = $locname; } return $locations;

« previous php.pear.cvs (#36151) next »