Files
thetool/application/ADBHausnummer/ADBHausnummer.php
2022-10-13 12:47:03 +02:00

71 lines
1.6 KiB
PHP

<?php
class ADBHausnummer extends mfBaseModel {
private $strasse;
private $plz;
private $freigaben = [];
protected function init() {
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$this->table = "Hausnummer";
}
/*
public static function parseAddresszusatz($text) {
$zusatz = "";
$text = trim($text);
if(!$text) return $data;
$text = " ".$text;
$m = [];
if(preg_match('/((?:gesch(?:ae|ä)ft|betrieb und wohnungen|paketlogistik|cafe|pavillon|pfarrheim|[^ ]*haus|[^ ]*geb(?:ae|ä)ude|[^ ]*halle)(?:\s+[a-z0-9]+)?)/i', $text, $m)) {
$zusatz = $m[1];
$text = str_replace($m[0], "", $text);
}
$text = trim(preg_replace('/\s{2,}/', "", $text));
if($text) {
$data['zusatz'] = $text;
}
return $data;
}*/
public function getProperty($name) {
if($this->$name == null) {
if($name == "freigaben") {
$this->freigaben = explode(",", $this->freigabe);
return $this->freigaben;
}
if($name == "strasse") {
$this->strasse = new ADBStrasse($this->strasse_id);
return $this->strasse;
}
if($name == "plz") {
$this->plz = new ADBPlz($this->plz_id);
return $this->plz;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
if($this->$name->id) {
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}