52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
class ADBNetzgebiet extends mfBaseModel {
|
|
|
|
protected function init() {
|
|
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
|
$this->table = "Netzgebiet";
|
|
}
|
|
|
|
public function loadByExtref($extref) {
|
|
$extref = $this->db->escape(trim($extref));
|
|
if(!$extref) {
|
|
return false;
|
|
}
|
|
|
|
$res = $this->db->select("Netzgebiet", "*", "extref='$extref'");
|
|
if(!$this->db->num_rows($res)) {
|
|
return false;
|
|
}
|
|
$data = $this->db->fetch_object($res);
|
|
$this->load($data);
|
|
return true;
|
|
}
|
|
|
|
public function getProperty($name) {
|
|
if($this->$name == null) {
|
|
|
|
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;
|
|
}
|
|
}
|