53 lines
1.1 KiB
PHP
53 lines
1.1 KiB
PHP
<?php
|
|
|
|
class ADBOrtschaft extends mfBaseModel {
|
|
private $gemeinde;
|
|
|
|
|
|
protected function init() {
|
|
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
|
$this->table = "Ortschaft";
|
|
}
|
|
|
|
public function find($search) {
|
|
$seach = $this->db->escape($search);
|
|
if(!$search) {
|
|
return false;
|
|
}
|
|
|
|
$results = [];
|
|
|
|
$res = $this->db->select("Ortschaft", "*", "name like '%$search%'");
|
|
if($this->db->num_rows($res)) {
|
|
while($data = $this->db->fetch_object($res)) {
|
|
$results[] = new ADBOrtschaft($data);
|
|
}
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
|
|
public function getProperty($name) {
|
|
if($this->$name == null) {
|
|
|
|
if($name == "gemeinde") {
|
|
$this->gemeinde = new ADBGemeinde($this->gemeinde_id);
|
|
return $this->gemeinde;
|
|
}
|
|
|
|
$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;
|
|
}
|
|
|
|
|
|
} |