Fixed Stiege issue in "ortschaft strasse" query

This commit is contained in:
Frank Schubert
2024-05-23 13:30:16 +02:00
parent eadb3f516a
commit 72c406766c

View File

@@ -517,8 +517,8 @@ class PreorderApicontroller extends mfBaseApicontroller {
foreach($address_search as $field => $value) {
if($field == "ortschaft" || $field == "gemeinde") continue;
if($field == "hausnummer_stiege" && !$value) {
$where .= " AND (`hausnummer_stiege` = '' OR hausnummer_stiege IS NULL)";
continue;
$where .= " AND (`hausnummer_stiege` = '' OR hausnummer_stiege IS NULL)";
continue;
}
$where .= " AND `$field` = '$value'";
}
@@ -531,11 +531,16 @@ class PreorderApicontroller extends mfBaseApicontroller {
$sql = "SELECT * FROM view_hausnummer WHERE $where";
$this->log->debug($sql);
$res = $this->db()->query($sql);
// If not found, try with Ortschaft in front of strasse (liezen gwr issue)
if(!$this->db()->num_rows($res)) {
// try with Ortschaft in front of strasse (liezen gwr issue)
$where = "1=1 ";
foreach($address_search as $field => $value) {
if($field == "ortschaft" || $field == "gemeinde") continue;
if($field == "hausnummer_stiege" && !$value) {
$where .= " AND (`hausnummer_stiege` = '' OR hausnummer_stiege IS NULL)";
continue;
}
if($field == "strasse") {
$prefix = ($address_search['ortschaft']) ? $address_search['ortschaft'] : $address_search['gemeinde'];