[Mapbender-commits] r1410 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu May 31 08:42:25 EDT 2007
Author: christoph
Date: 2007-05-31 08:42:25 -0400 (Thu, 31 May 2007)
New Revision: 1410
Modified:
trunk/mapbender/http/php/mod_gazetteerSQL_server.php
Log:
added a new address search (without commune restriction)
Modified: trunk/mapbender/http/php/mod_gazetteerSQL_server.php
===================================================================
--- trunk/mapbender/http/php/mod_gazetteerSQL_server.php 2007-05-31 12:41:57 UTC (rev 1409)
+++ trunk/mapbender/http/php/mod_gazetteerSQL_server.php 2007-05-31 12:42:25 UTC (rev 1410)
@@ -5,8 +5,7 @@
require_once(dirname(__FILE__)."/../classes/class_mb_exception.php");
require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
require_once(dirname(__FILE__)."/../../conf/gazetteerSQL.conf");
-
-//$connstring = " user=" . OWNER . " dbname=".SQL_SEARCH_DBNAME." host=".DBSERVER." password=".PW;
+$connstring = " user=" . OWNER . " dbname=infokom host=".DBSERVER." password=".PW;
$con = pg_connect($connstring);
$command = $_GET["command"];
@@ -59,9 +58,16 @@
else if ($command == "getStreets") {
$obj["streets"] = array();
- $sql = "SELECT DISTINCT strk_schl, str_name FROM alb.navigation WHERE gkz = $1 ORDER BY str_name";
- $v = array($communeId);
- $t = array("i");
+ if (!empty($communeId)) {
+ $sql = "SELECT DISTINCT strk_schl, str_name FROM alb.navigation WHERE gkz = $1 ORDER BY str_name";
+ $v = array($communeId);
+ $t = array("i");
+ }
+ else {
+ $sql = "SELECT DISTINCT strk_schl, str_name FROM alb.navigation ORDER BY str_name";
+ $v = array();
+ $t = array();
+ }
$res = db_prep_query($sql, $v, $t);
while($row = db_fetch_array($res)){
$streetId = trim($row["strk_schl"]);
@@ -72,13 +78,21 @@
}
else if ($command == "getNumbers") {
$obj["houseNumbers"] = array();
+ $paramCounter = 0;
- $sql = "SELECT DISTINCT hnr, hnrzu, rw, hw FROM alb.navigation WHERE gkz = $1 AND str_name ILIKE $2 ORDER BY hnr, hnrzu";
- $v = array($communeId, $streetName."%");
- $t = array("i", "s");
+ if (!empty($communeId)) {
+ $sql = "SELECT DISTINCT hnr, hnrzu, rw, hw FROM alb.navigation WHERE gkz = $". ++$paramCount ." AND str_name ILIKE $". ++$paramCount ." ORDER BY hnr, hnrzu";
+ $v = array($communeId, $streetName."%");
+ $t = array("i", "s");
+ }
+ else {
+ $sql = "SELECT DISTINCT hnr, hnrzu, rw, hw FROM alb.navigation WHERE str_name ILIKE $". ++$paramCount ." ORDER BY hnr, hnrzu";
+ $v = array($streetName."%");
+ $t = array("s");
+ }
if (isLimited($numberOfResults)) {
- $sql .= " LIMIT $2";
+ $sql .= " LIMIT $". ++$paramCount;
array_push($v, $limit);
array_push($t, "i");
}
More information about the Mapbender_commits
mailing list